Wednesday, 19 March 2014

Speed Up your Website by Enabling Browser cache

When you create a website,the main success factor of that website would be its speed. But however we tried to increase a website speed it takes some default time to load a page. Here am trying to explain about 
Browser caching.
Before moving to the tricks,I will explain what is browser caching?? and what is the significance of it??
When a web browser displays your webpage it has to load several things like your logo, your CSS file, and other resources.

What browser caching does is "remember" the resources that the browser has already loaded. This means that when a visitor goes to another page on your website it does not have to go get your logo or CSS file again, because it already has it "remembered". The end result of this is that your pages load much faster.

If you have tested your webpage for speed and found out that you need to use browser caching, here is how you do it.

To acheive this you have to write something in your htaccess file.
Open your htaccess files and add lines below:-

</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/js "access plus 1 year"
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 2 days"
</IfModule>

Here You can set its expire period too.
Change the period you want after access plus . For eg: access plus 1 month, access plus 1 week, access plus 1 year are vaild statements.

Save your htaccess file and refresh the page. 


No comments:

Post a Comment