Search code examples
.netinternet-explorerbrowsercachingdisable-caching

Force IE to get a page


I've tried numerous ways to get IE8 to reload a page but failed. IE just keeps using it's internal cache without asking the webserver for it.

I'm sending the following headers from my webserver:

Response.Add(new StringHeader("Expires", DateTime.UtcNow.AddYears(-1).ToString("r")));
Response.Add(new StringHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0"));
Response.Add(new StringHeader("Pragma", "no-cache"));
Response.Add(new StringHeader("Last-Modified", DateTime.UtcNow.ToString("r")));

It's just one of many combinations that I've tried.

How do I make IE fetch the page every time (without forcing my users to turn off caching inside IE)?


Solution

  • The proper way is to send these HTTP headers in the response:

    Pragma: no-cache
    Expires: -1
    Cache-Control: no-cache, no-store
    

    Using them makes everything work in IE without any other modifications.