Leverage browser caching

One of the easiest way to improve your site’s speed optimization is by enabling leverage browser caching.
This is one of the most important speed optimization steps. Google PageSpeed Insights takes Leverage browser caching into consideration too.

All you need to do is update your .htaccess file with the following content. I recommend to put this code at very top of your .htaccess file.

Each line sets a expiration date to various files, and let browser know for how long each file should be cached.

This doesn’t control your external files that you load to your web page.

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"

To check if your changes where successful you can double check it using Google PageSpeed Insights.

It will either come up in completed list or to do list.

If you have any problems feel free to contact me or leave a comment.