0
Ajax and IE 7: cache not invalidating
For the past day or two I had been struggling at work to figure out why Internet Explore 7 would not pay attention to the response headers stating not to cache the response. First, I tried setting the date header to expire instantly, with a value of -1. QA confirmed that this solved the problem in some revisions of IE 7 but not all. After digging around the web it turns out that you have to set a few more headers, one of which I had never even heard of. Here’s what solved the problem for me. This snippet is in Java but could apply to any language:
response.setDateHeader( "Expires", -1 ); response.setHeader( "Cache-Control", "private" ); response.setHeader( "Last-Modified", new Date().toString() ); response.setHeader( "Pragma", "no-cache" ); response.setHeader( "Cache-Control", "no-store, no-cache, must-revalidate" );
Categories: Computers, Software