Prevent Caching of pages in all Browsers

By samjayander thiagarajan

How to Prevent Caching of pages in Asp.net - A Cross Browser solution.

When you want to prevent caching of page in asp.net you may use the
Cache-Control to "no-cache"

But it will not work with Firefox. In Firefox this attribute will only prevent the HTTPS pages.

To fix the issue in Firefox also, you need to use
Cache-Control to "no-store"

eg:
<meta http-equiv="Cache-Control" CONTENT="no-cache">

In asp.net code-behind you can use this:

Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(0,1,0));
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.Cache.SetNoStore();

Prevent Caching of pages in all Browsers  (1288 Views)