Htaccess leverage browser caching

Htaccess leverage browser caching, someone asked me to explain?

cached version of website

We can specify the browsers, how long time to keep css ,JS and images stored locally using the .htaccess file i.e( leverage browser caching of static assets). Using google PageSpeed Insights, we can find out how to make our web pages faster on all devices, after giving the web page URL on the text box and clicking the analyze button.

You have to add the following text to the .httaccess file. It will instruct the browser to load previously downloaded resources from the local disk rather than over the network.

Leverage browser caching htaccess code:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault"access plus 10 days"
    ExpiresByType text/css"access plus 1 week"
    ExpiresByType text/plain"access plus 1 month"
    ExpiresByType image/gif"access plus 1 month"
    ExpiresByType image/png"access plus 1 month"
    ExpiresByType image/jpeg"access plus 1 month"
    ExpiresByTypeapplication/x-javascript "access plus 1 month"
    ExpiresByTypeapplication/javascript "access plus 1 week"
    ExpiresByTypeapplication/x-icon "access plus 1 year"

But for Godaddy windows hosting, it will not work. So,you need to create caching rules in web.config configuration file to enhance the website speed.

System webserver caching:

      <clientCache cacheControlMode="UseExpires"
         httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />

Also add the following code at the top of the .htaccess file.

<IfModule pagespeed_module>
ModPagespeed on
# using commands,filters etc



Post your comments / questions