Microsoft Internet Explorer cache issues

 

Internet Explorer implements caching for GET requests. Authors who are not familiar with HTTP caching expect GET requests not to be cached, or for the cache to be avoided as with the refresh button. In some situations, failing to circumvent caching is a bug. One solution to this is to use the POST request method, which is never cached; however, it is intended for non-idempotent operations.

Setting the "Expires" header to reference a date in the past will avoid caching of the response. Here is an example in PHP.

header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
// disable IE caching header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); 
header( "Cache-Control: no-cache, must-revalidate" ); header( "Pragma: no-cache" );
 

Caching may also be disabled, as in this Java Servlet example.

response.setHeader( "Pragma", "no-cache" ); 
response.addHeader( "Cache-Control", "must-revalidate" ); 
response.addHeader( "Cache-Control", "no-cache" ); 
response.addHeader( "Cache-Control", "no-store" ); 
response.setDateHeader("Expires", 0);
 

Caching disabled in this C# Handler example which forces all proxy caches to revalidate, prevents browser from caching and expires the response:

context.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); 
context.Response.Cache.SetCacheability(HttpCacheability.NoCache); 
context.Response.Cache.SetNoStore(); 
context.Response.Cache.SetNoServerCaching(); 
context.Response.Cache.SetExpires(DateTime.Now); 
 

Alternatively, it is possible to force the XMLHttpRequest object to retrieve the content anyway, as shown in this example.

req.open( "GET", "xmlprovider.php" ); 
req.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" ); 
//This line doesn't work. 
req.send( null ); 

Another method is to add a random string on the end of the url in the query:

req.open( "GET", "xmlprovider.php?sid=" + Math.random());
 

This will ensure that the browser always gets a fresh copy.

It is important to note that these techniques should be used only if the caching is inappropriate. If such methods are used indiscriminately, poor performance with the application may result. Another better way around that may be sending an expired date/time header (or other relevant headers) to the client to gain benefits from caching while letting the client know that new data may be available, as generally it is better to obtain the performance benefits from caching to reduce processing time and bandwidth consumption.


대부분 간단히 요청주소에 현재 시간을 덧붙여서 전송합니다.
'action.php?t=1144760075' 이런식으로요.. 주소가 달라지니 캐시도 사용되지 않겠죠.

req.open("GET", "xmlprovider.php?hash=" + Math.random());
위와 같이 캐쉬를 하지않게 호출할때 마다 요청에 유일한 쿼리스트링을 포함함돠