Home > Website > How to leverage browser cache?

How to leverage browser cache?

Leveraging browser cache can greatly improve your website speed and save resource usage by caching part of the website content in your visitor's browser. To use it, you will need to paste the following code anywhere in your .htaccess file (you might need to create this file if it does not exist):
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 7 days"

Once the following code is saved in your .htaccess, you can test whether it was successful by scanning your website using tools such as GTMetrix. It should produce similar results: