Pingdom.com test and Google Page Speed Insights give me the same Browser Leverage Cache failure.
I use this in .htaccess:
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
</IfModule>
Though, If I check with Developer Network Tools in Chrome, I see the results I expect.
Example:
Google Test says that both files "jquery-ui.css" and "home.css" are set to expire in 60 minutes.
But, when I check using Chromes Developer Tools in the browser it displays that they expire in one month as they are supposed to.
Could there be a reason these tests can't read my site properly?
It seems my server was using "mod_deflate" (Apache). This must have been tricking the testing sites.
What fixed it was changing my .htaccess calls to:
# mod_deflate
# 1 YEAR
ExpiresActive On
<FilesMatch "\.(otf|ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
ExpiresDefault "access plus 1 years"
Header unset Last-Modified
Header unset ETag
SetOutputFilter DEFLATE
</FilesMatch>
# 1 MONTHS
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2419200, public"
ExpiresDefault "access plus 1 month"
SetOutputFilter DEFLATE
</FilesMatch>
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=604800, public"
ExpiresDefault "access plus 1 month"
SetOutputFilter DEFLATE
</FilesMatch>
# 30 MIN
<FilesMatch "\.(html|htm|php)$">
SetOutputFilter DEFLATE
</FilesMatch>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.