some php files caching and some are not

I guess I’m missing something, obviously.

I have in the .htaccess file to cache css & js files:

Enable expiration control

ExpiresActive On

# Default expiration: 1 month after request
ExpiresDefault "access plus 1 month"

CSS and JS expiration: 1 week after request

ExpiresByType text/css "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"

However, the test results show browser caching is 24hrs, and there is no css & js caching:

http://www.webpagetest.org/performance_optimization.php?test=121122_QV_47H&run=1&cached=0

DO I not have my .htaccess file correct? Is this set in the cPanel php EZconfig menu?

-Jay

General stuff…

  • is mod_expires installed?
  • Is your web server set up to process .htaccess?

Here’s a pretty short lived setup… ensuring .php is not cached. You will have to wait until the current caching expires, or use a new browser / log in as someone else…

ExpiresActive On

Images cached for a day…

ExpiresByType image/gif “access plus 1 day”
ExpiresByType image/png “access plus 1 day”
ExpiresByType image/x-icon “access plus 1 day”

Make sure dynamic stuff stays so.

<FilesMatch “.php$”>
ExpiresByType text/html “now”

Thanks for replying, GreenGecko.

I do have mod_expires loaded and apache is set to allow processing htaccess.

You mention waiting “until your current caching expires or use another web browser…”. Why would I need to wait on the caching to expire? If I am making the changes to .htaccess, flush the cache on my Backend, and then run the webpage test, should the results not reflect those changes on that subsequent test?

I changed the htaccess mod_expires & mod_header settings to this:

#####################################################

ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType text/html "access plus 1 seconds" ExpiresByType text/css "access plus 31536000 seconds" ExpiresByType text/javascript "access plus 31536000 seconds" ExpiresByType application/javascript "access plus 31536000 seconds" ExpiresByType application/x-javascript "access plus 31536000 seconds" ExpiresByType image/ico "access plus 31536000 seconds" ExpiresByType image/gif "access plus 31536000 seconds" ExpiresByType image/jpg "access plus 31536000 seconds" ExpiresByType image/jpeg "access plus 31536000 seconds" ExpiresByType image/png "access plus 31536000 seconds" ExpiresByType image/bmp "access plus 31536000 seconds" Header set Cache-Control "max-age=31536000, public" Header set Cache-Control "max-age=31536000, public" Header set Cache-Control "max-age=31536000, private" Header set Cache-Control "max-age=31536000, public, must-revalidate" Header set Cache-Control "max-age=1, private, must-revalidate" Header unset ETag

FileETag None

Header unset Last-Modified

#####################################################

And it gave me an FAAAA score (shared hosting):
http://www.webpagetest.org/performance_optimization.php?test=121127_ZR_79P&run=1&cached=0

Tweaked ExpiresDefault to 5sec, and got an FAAAC:
http://www.webpagetest.org/performance_optimization.php?test=121127_D4_7Y0&run=1&cached=0

I thought ‘no way that one setting changed that’. So I changed it back to 1sec, and still came up with FAAAC.

I noticed that in the run that reported the FAAAA, it sent css files and not php files like subsequent & prior test. I also noticed that with the FAAAA test, the TTFB was 0.812s - down from the normal ~2.5s. Huh?

Can someone help me understand this?

My guess is that you have a plugin that optimizes/combines the resources and it didn’t kick in on the first test but when it did kick in you got the .php resources.

The idea of having an expiry date on a file is that is is stored on your browser until the expiry time, so will not attempt to download the file (or even check) until that time expires.

So changes to the backend / .htaccess are irrelevant. It has it and knows when it’s valid until. Look at the repeat waterfall on this very site for an example.