Reputation: 2878
I set up a subdomain on my site purely to improve site speed (to spread HTTP requests over multiple, cookieless domains, as recommended by Google). I've been experimenting and it looks like my .htaccess caching settings aren't having the same effect on the subdomain.
Compare these two URLs and their response/caching times:
http://www.scenepointblank.com/assets/img/features/coming_in_2012_homepage.png (original) http://img.scenepointblank.com/features/coming_in_2012_homepage.png (subdomain)
Looking at the response headers it seems to have picked up the same cache_control
, but the actual response times vary quite massively (I see an average of ~400ms for www
and ~4s for img
).
My .htaccess file is at the root of the domain and to experiment I also put a duplicate in scenepointblank.com/assets/img/
to no effect. The contents of the file are below:
FileETag MTime Size
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
<FilesMatch .php$>
# Do not allow PHP scripts to be cached unless they explicitly send cache
# headers themselves. Otherwise all scripts would have to overwrite the
# headers set by mod_expires if they want another caching behavior.
ExpiresActive Off
</FilesMatch>
</IfModule>
# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
Any ideas why this could be happening?
Upvotes: 0
Views: 1273
Reputation: 2878
Seem to have fixed this by adding the following to .htaccess:
ExpiresActive On
ExpiresByType image/png "now plus 365 days"
ExpiresByType image/jpeg "now plus 365 days"
ExpiresByType image/gif "now plus 365 days"
ExpiresByType text/css "now plus 365 days"
Upvotes: 1