[Solved] How to Address the “Expiration Not Specified” Message In Google PageSpeed Insights
We’ll give you some lines of code to add to your .htaccess file and walk you through the whole process.
Let’s fix the message “Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network”
- Log into your hosting
- Go to your .htaccess file
- Add this code to the .htaccess file:
# BEGIN EXPIRES
ExpiresActive On
ExpiresDefault “access plus 10 days”
ExpiresByType text/css “access plus 1 week”
ExpiresByType text/plain “access plus 1 month”
ExpiresByType image/svg+xml “access 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 week”
ExpiresByType application/x-icon “access plus 1 year”# END EXPIRES
(make sure there are no indentations, this can potentially cause errors)
- Save the .htaccess file.
Read on if you need a bit more guidance…
Site load speed is important for two reasons: user experience and SEO. Needless to say, with Google getting ready to penalize mobile sites for slow load times, it’s important to make sure that your site is as fast as it can be. But you already know this.
So you’ve gotten this message…
and you want to see this:
Although you may think that doing this with a plugin would be easier, my experience has been that it is not easier. WP Cache wouldn’t allow me to do this at all and W3 Total Cache ended up crashing my site, leading to several hours of trying to fix whatever it broke. Ultimately, adding a script to my .htaccess file did the trick.
Log into your file manager on your hosting
You should see this screen at the root of the website that you are trying to work on:
You are going to edit your .htaccess file by adding the following code:
# BEGIN EXPIRES
ExpiresActive On
ExpiresDefault “access plus 10 days”
ExpiresByType text/css “access plus 1 week”
ExpiresByType text/plain “access plus 1 month”
ExpiresByType image/svg+xml “access 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 week”
ExpiresByType application/x-icon “access plus 1 year”
# END EXPIRES
Save it and check that it worked
You should make sure that you saved the .htaccess file, then try PageSpeed insights. There’s a good chance that you just hit the green!