Page speed is an important ranking factor with Google and other search engines; it is also crucial to decrease bounce rates. If they have to wait for longer than a few seconds, searchers tend to move on. After all, there are millions of other Google hits to try, and they’ll choose one that loads quickly. This is where expires headers come in handy. What are they, and how do you add them?
What are Expires Headers?
Typically, when a searcher looks for information, the browser sends a request to the server for the data, whether it’s an image or text file. All of this is done very quickly; what you can do to improve load speeds is to set expires headers for specific resources. The browser will store these, and when someone revisits the site, the page will load much more quickly because those images, files, etc., are readily available. They don’t have to be requested from the server.
The expires header indicates that the file or resource be stored, and you are able to set a date for it to expire. When doing this, you want to cache information that will need to be recalled; for instance, if someone has items in his shopping cart and accesses the site two weeks later, those items need to be there. You do not want to add this header to information that will be changed or updated with more frequency.
How to Add Expires Headers?
- Decide which items you want to have cached and readily available and determine the expiry date. You can use anything from years to seconds. Two examples:
ExpiresDefault “access plus 3 years”
Expires Default “access plus 2 days”
This indicates that the browser will cache this information for the user’s initial access plus a period of 3 years, or of 2 days, or whatever you decide.
- To your .htaccess file, add:
<filesMatch “.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$”>
Header set Expires “access plus 2 days”
</filesMatch>
This can be a great way to speed up load time without investing in complex or expensive redesigns or infrastructure.