Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Old 10-25-2010, 05:10 AM PHP/APACHE Caching
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
Im currently using the ob_start("gz_handler"); to gzip all the contents in my php file. I am also using my .htaccess file to set the expires headers and to check whether the content has been modified or not.

I was wondering considering that i might want to make changes to the design in the future that i split the page into 3 different files, header.php content_name.php and footer.php, this would allow me to edit one file instead of having to keep making the same changes to each individual page if i was to keep them all as one.

Would this have any problems on caching if i included the files via a php include.

Code:

PHP Code:
<?php ob_start("gz_handler");
include(
"header.php");
includer("content_name.php");
include(
"footer.php");
?>
.HTACCESS Code:

Code:
<IfModule mod_headers.c>
# Turn on Expires and set default expires to 3 days
ExpiresActive On
ExpiresDefault A259200
 
# Set up caching on media files for 1 month
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
  ExpiresDefault A2419200
  Header append Cache-Control "public"
</FilesMatch>
 
# Set up 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
  ExpiresDefault A7200
  Header append Cache-Control "private, must-revalidate"
</FilesMatch>
 
# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
  ExpiresDefault A0
  Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
  Header set Pragma "no-cache"
</FilesMatch>
</IfModule>
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
 
Register now for full access!
Old 10-26-2010, 04:30 PM Re: PHP/APACHE Caching
Crimson's Avatar
Skilled Talker

Posts: 56
Name: Connor
Location: United States
Trades: 0
Using PHP includes don't affect .htaccess caching (or "HTTP caching" as it's more technically called), so you shouldn't have any problems with that.

If you're interested in caching, though, you might consider looking into using a PHP accelerator like the Alternative PHP Cache (APC). This can speed up your PHP script hugely.

Hope this helps.
__________________

Please login or register to view this content. Registration is FREE

I solve code problems, browser compatibility (including IE 6), Wordpress trouble, the works.
Crimson is offline
Reply With Quote
View Public Profile Visit Crimson's homepage!
 
Old 10-26-2010, 06:05 PM Re: PHP/APACHE Caching
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
Thanks, for info.

Last edited by evans123; 10-26-2010 at 06:08 PM..
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
Old 10-28-2010, 03:53 AM Re: PHP/APACHE Caching
Junior Talker

Posts: 3
Name: josiebourne
Trades: 0
Try adding this to your php page
This will Disable all caching
PHP Code:

if(!strpos(strtolower($_SERVER[HTTP_USER_AGENT]), "msie") === FALSE) {
   
header("HTTP/1.x 205 OK");
} else {
   
header("HTTP/1.x 200 OK");
}    
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, cachehack=".time());
header("Cache-Control: no-store, must-revalidate");
header("Cache-Control: post-check=-1, pre-check=-1"false); 
__________________

Please login or register to view this content. Registration is FREE

Last edited by chrishirst; 10-31-2010 at 04:42 PM..
josiebourne is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP/APACHE Caching
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13460 seconds with 12 queries