We’ll give you some lines of code to add to your .htaccess file and walk you through the whole process.
How to 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”
Site load speed is important for two reasons: user experience and SEO. Needless to say, with Google getting ready to reward and penalize mobile sites for their 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
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-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!