Search code examples
htmlinternet-explorerhttpshttp-caching

prevent caching on https without breaking IE


Some of the downloads we have in our webapplication are generated and should not be cached by the browser.

When using HTTP:// we can prevent this with the header: Cache-Control : no-cache

However this break is IE:

http://support.microsoft.com/kb/2549423

http://support.microsoft.com/kb/812935

http://support.microsoft.com/kb/316431 (related problem)

The common solution to the IE problem is to not send these headers. But removing these headers opens up the possibility of browser caching these resources again (which is unwanted).

Is there a clean (preferably content unaware) way to prevent caching in all common browsers yet not break downloads for IE?


Solution

  • If the server part of your web application ignores additional request parameters, how about changing

    http://mywebapplication/service?param=value
    

    to

    http://mywebapplication/service?param=value&garbage=889jsdakd8932hd
    

    I.e., on the client side:

    url = 'http://mywebapplication/service';
    url += '?garbage=';
    
    for (var i = 0; i < 20; i++)
        url += Math.floor(10 * Math.random());
    

    This would convince the browser you are downloading a new resource every time.