Top Nav

Preventing Caching

When it comes to preventing caching, there are a couple of annoying
Javascripts you can use, but I wouldn’t recommend it. Until there is a
technology specifically developed to prevent caching as an option on the
client side, there are a few options.
The best I’ve seen so far is the META and Pragma options in which either
you don’t cache the whole page itself, or make sure the page is always

1. Using the ‘Expires’ header. The Expires header of an HTML document
tells a Web browser when a cached document should expire from the cache.
Using a date in the past ensures the document will always be expired.

Insert the text below between the <HEAD></HEAD> tags of the HTML
document containing the embedded file.

<META HTTP-EQUIV=”Expires” CONTENT=”Mon, 04 Dec 1999 21:29:02 GMT”>

Each and every time this document is requested the browser will notice
that the cached version has expired and will download the file from it’s
server of origin. (Which by the way, beats the pants off of tweaking
your .htaccess file).

2. Using the Pragma: No-Cache header. This code directs the browser to
not cache the document at all.

Insert the following text after the closing </BODY> tag of the HTML page
containing the embedded file.


It’s important to note here that the Pragma: No-Cache header does not
work with Internet Explorer 5. Microsoft higly recommends using the
Cache-Control header, instead. Check out their article on this
particular subject at

3. As a third option, when linking between HTML pages, it’s possible to
force the linked page to be loaded from it’s server of origin and not
from the browser cache. To do this simply place a query-string operator,
?, followed by a number on the end of the link URL.

For example, if one HTML page contains a link to another page called
‘mypage.html’, then to force the browser to download the latest version
of that page from the Web server set up the link in the HTML page like

<a HREF=”mypage.html?1″>Some Link</a>

I recommend that you use both method 1 and 2 together on any page that
contains sensitive material. (images, swf files, etc.)