04 · 12

How-To Prevent Browser Caching of Web Pages

* As posted on Top Cultured * Awh, browser caching. What a great tool to have but what a pain for web developers! If you are a web developer you know exactly what I am talking about. If you don't know what browser caching is, here is a brief explanation:
When you go to a specific page in your web browser, the browser caches that page in its memory so that when you access it again, instead of loading the page, it pulls the cached version.
Can you see where this can be great? Well, caching allows the web page to load faster since the browser doesn't have load it from the internet, instead loading it from the cached file. But this can also be a pain for us web developers! In my experience (and probably yours too), when making updates to a client's website, 9 times out of 10 the client's browser is caching those pages. So when they pull up the page, it shows the older (cached) page instead of the newly updated one. You know what happens next... So how do you prevent browsers to cache web pages? Well the code below, when put on every page within the <head></head> section, will tell the browsers NOT to cache the page. Here is the code:
<meta http-equiv="expires" value="Thu, 16 Mar 2001 11:00:00 CST" /> <meta http-equiv="pragma" content="no-cache" />
By putting the date is the past (which is already expired) the browser will not cache the page. ~ Kyle Reddoch