I've been through over 100 answers here, lots to try, NOTHING working??
Have a PHP based site. I need caching OFF for all .php files EXCEPT A SELECT FEW.
So, in .htaccess, I have the following:
ExpiresActive On
# Eliminate caching for certain dynamic files
<FilesMatch "\.(php|cgi|pl)$">
ExpiresDefault A0
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
Using Firebug, I see the following:
Cache-Control no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform
Connection Keep-Alive
Content-Type text/html
Date Sun, 02 Sep 2012 19:22:27 GMT
Expires Sun, 02 Sep 2012 19:22:27 GMT
Keep-Alive timeout=3, max=100
Pragma no-cache
Server Apache
Transfer-Encoding chunked
X-Powered-By PHP/5.2.17
Hey, Looks great!
BUT, I have a couple .php pages I need some very short caching on.
I thought the simple answer was having this added to the very top of each php page in which I want caching enabled:
<?php header("Cache-Control: max-age=360"); ?>
Nope.
Then I tried various versions of the above. Nope.
Then I tried meta http-equiv variations. Nope.
Then I tried variations of the .htaccess code along with the above variations, such as limiting it to:
# Eliminate caching for certain dynamic files
<FilesMatch "\.(php|cgi|pl)$">
Header set Cache-Control "no-cache, max-age=0"
</FilesMatch>
Nope.
It seems nothing I do will allow a single .php to be cache enabled with the .htaccess code in place, short of removing the statements from the .htaccess file altogether.
Where am I going wrong? What do I have to do to get individual php pages to be cacheable while the rest remain off??
Thank you for any thoughts.