I used Chrome to audit my site and I discovered .js and .css files weren’t being cached though I had set up my .htaccess file to do so.
I removed everything from my site’s root htaccess file except the code below and I’m still getting the message “The following resources are explicitly non-cacheable. Consider making them cacheable if possible” in Chrome indicating my main external .js and .css files aren’t being cached. These files and images represent like 90% of the total download size so not being able to cache them is driving me crazy.
This is currently the code of my .htaccess file. Having it exactly like this still doens’t cache anything.
# Disable Etags
Header unset ETag
FileETag None
# Expires
ExpiresActive On
ExpiresDefault "access plus 1 year"
Header unset Last-Modified
Header set Cache-Control "public"
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi|html?)$">
Header set Cache-Control "private, must-revalidate, proxy-revalidate"
ExpiresDefault A0
ExpiresActive Off
</FilesMatch>
# Enable Compresion
<FilesMatch ".(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
You can see this code not working at http://lujanventas.com
How can I set cache control public to .css, .js and image files?
At the moment of writing, your running server generates headers that way for JavaScript:
This is incorrect, it should have been replaced by effective date and time. So it explains no browser is able to cache the resource properly.
According to documentation, there is no reason why it does not work.
Is there any hidden character in your configuration that prevents Apache2 to parse the line properly ? Try to delete the line
ExpiresDefaultline and type it again from scratch in an reliable text editor.If still failing, where does your Apache2 version/binary comes from ?