IE8 aggressive caching fix

Apparently Internet Explorer 8 has a more aggressive caching mechanism than any other browser I’ve ever met. To fix it I’ve added the following to almost every dynamic page on my server.

<%
// prevent caching (asp classic jscript)
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
%>
<%
' prevent caching (asp classic vbscript) '
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>
<?php
// prevent caching (php)
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header('Expires: ' . gmdate(DATE_RFC1123, time()-1));
?>
// prevent caching (C#)
//Response.AddHeader("Cache-Control", "no-cache");
//Response.AddHeader("Pragma", "no-cache");
//Response.Expires = -1;

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.MinValue);

More information here: How to prevent caching in Internet Explorer

Comments are closed.