Saturday 9 August 2014

Leverage Browser Caching Code .htaccess

How to Leverage Browse Caching of Your Website and Blog Via .htaccess?



We should always be looking for methods to enhance the performance of our website or Blog. One of the simplest methods to enhance our website or blog performance and speed is to leverage browser caching.

If you have checked your website for speed and noticed that you need to leverage browser caching code, here is how you do it.

How to Enable The Leverage Browser Caching Code?

The best common way is to add code to a file known as .htaccess on your server/host.

The .htaccess file manages many crucial things for your website.  Mentioned below code tells browsers what to cache and how long to "remember" it.  It should be added to the top or bottom of your .htaccess file.



## EXPIRES CACHING ##
<IfModule mod_expires.c>
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"
</IfModule>
## EXPIRES CACHING ##

Refresh your browser after save the .htaccess file.

No comments:

Post a Comment