c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
SEO

Htaccess leverage browser caching

| | SEO-tips , webconfig

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:

# BEGIN EXPIRES
<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"
</IfModule>
# END EXPIRES

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:

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseExpires"
         httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />
    </staticContent>
  </system.webServer>
</
configuration>

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

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