To cache or not to cache

No cache

No cache

What exactly is a browser cache and should we stop it being used?

What’s a browser cache

Let’s start off with what exactly is a browser cache.  A browser cache is a copy of the web pages and all the supporting files such as images you have viewed in the past that are stored on your computer so that next time you  look at them your computer doesn’t have to connect to the Internet and download them again. This way you not only get to see them quicker but they don’t use any further bandwidth to download them again.

This is generally a good thing for the person viewing a web site and the Internet as a whole. For example lets just take the image at the top of this page, well it’s at the top of every page, but your computer has now cached it and so when you click on a link to go to another page on this site your browser will get the cached version stored on your computer rather than fetch it from the Internet. This results in it not only showing more quickly but doesn’t use your Internet connection for this image and more importantly reduces the amount of traffic on the Internet. If no web pages were cached on the Internet at all we would all have a much different experience than we do now as things would be so much slower due to the vast amount of traffic going around.

So generally it seems the browser cache is a great idea but it can also be a problem for some.

Clear your cache

When you are having some changes to your web site and you get an email from your web guy telling you it’s all done, you look and can’t see any difference. You complain and he tells you to clear your cache!!! This is one of those moments where you don’t want your browser caching your web site because you want to see the changes now. So you goole ‘clearing your cache’ and follow the instructions and hey presto you can see the changes, simple. Usually yes it is, however sometimes it’s not quite so simple.  For some browsers their cache clearing routine doesn’t clear everything and if your site is a dynamic site with lots of javascript, ajax and CSS some of these files are not cleared so you still see your cached version.

Don’t despair

There is a way around this but may cost you a little more in development costs.  Make sure that when ever your developers do updates to your supporting files that they change the file name of the file. That way your browser will have never have seen that file before and download from the Internet. The other thing to ensure they do is to add a no cache directive to the main index file as this file name cannot be changed.  This will also ensure your visitors will also see the change

This entry was posted in Techtorial and tagged . Bookmark the permalink.

Leave a Reply