WebPagetest Forums

Full Version: some php files caching and some are not
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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_o...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...

<IfModule mod_expires.c>
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"
</FilesMatch>
</IfModule>
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:

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

<ifModule mod_expires.c>
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"
</ifModule>

<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
<filesMatch "\\.(js)$">
Header set Cache-Control "max-age=31536000, private"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=31536000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>

<ifModule mod_headers.c>
Header unset ETag
</ifModule>

FileETag None
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
#####################################################

And it gave me an FAAAA score (shared hosting):
http://www.webpagetest.org/performance_o...1&cached=0

Tweaked ExpiresDefault to 5sec, and got an FAAAC:
http://www.webpagetest.org/performance_o...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.
(11-27-2012 11:28 AM)jamesdeanreeves Wrote: [ -> ]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?

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.
Reference URL's