Frank Olivo

Frank Olivo is the founder of Sagapixel. He writes on a number of topics related to digital marketing, but focuses mostly on SEO.

How To Fix The “Expiration Not Specified” Message In Google PageSpeed Insights

Category:
Table of Contents

[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”

  1. Log into your hosting
  2. Go to your .htaccess file
  3. 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)

  1. 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…

Setting an expiry date or a maximum age in the HTTP headers

and you want to see this:

90 google page speed

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:

screenshot of file manager within cpanel

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!

Schedule a call with us