Home   |   About   |   Terms   |   Contact    
A platform for writers

What is browser cache?

Web Design & Development

◄ All Articles

Popular Google Pages:

◕ Send your story to RiyaButu.com and get ₹ 500/- Details..

◕ Bengali Story writing competition. Details..

This article is regarding:
What is browser cache?
How to leverage browser caching of your website?
Browser Caching with .htaccess

Last updated on: .

What is browser cache? When a browser displays our Webpage, it has to load several things like our logo, CSS file, javascript and other resources. The browser can remember these loaded resource files and can store them on the visitors local computer for a long time and also can use them again and again. So if the visitor goes from one page to another or he returns back to my Webpage after a long time, then there is no need for the browser to load that resource files again. It just share and use that files which it stored bofore in its cache i.e browser cache. As a result our page will load very fast. So the speed of the Website will automatically increase and this impacts the ranking.

But for this we have to give instruction to the browser to save our resource files in it's cache. And this is done with the .htaccess file. This file is just a text file in our Root Directory. But be careful because this is a very powerful file. Read more about how to create and edit a .htaccess file.

Browser Caching with .htaccess

You can put these codes according to your requirement on your .htaccess file and save the file and refresh your page.

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"

On the above code you can add or delete a line or can change the time periods according to your requirement.

For an example:

◕ We can add a line of code for all PNG images for 24 hours.
The code will be:
ExpiresByType image/png "access 24 hour"

Here all PNG image will cached for 24 hours.

◕ Similarly in the above code
ExpiresByType text/css "access 1 month"
Means all css file will cached for 1 month.

Please note:

Let, you have cached your css file for 1 year. And you change something on that file after 2 months. But this change will not show on some User's Webpage because the old css file is already cached there before. In other word I can say, your old css file is already cached. So the browser will not cache the same file with the same name within the declared limit of time.

To avoid this situation you have to change the name of that old file in which you want to edit something new.

All the best!

Related articles:
► URL Redirection with .htaccess
► Ask Google to re-crawl your URL.
► Display HTML codes in HTML WebPage.
► Image Optimization

Top of the page

Amazon & Flipkart Special Products


Top of the page