Friday, January 9, 2015

Keeping a web page out of the cache

Recently I started maintaining a server for internal testing at work. This hosts, among other things, many web pages that we often modify.

Trying to make sure that we can modify the page and not have to wait an ungodly amount of time before the page goes out of the server's cache (not the client side browser cache) thereby now showing our changes, turned out to be a problem.

The solution we finally figured out was to add these meta tags to the head of the HTML.

<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title>Web Page Title< /title>
And while on the subject of Meta Tags, here's a meta tag to force the newer IE compatibility mode on a web page:
<meta content="IE=edge" http-equiv="X-UA-Compatible" />