Sergej Andrejev
Sergej Andrejev

Reputation: 9413

Can I clear browser cache of the page leaving page?

Can I clear browser cache of the page when I'm leaving it.

// Clear browser cache
Response.Redirect("otherpage.html");

By "clean browser cache" I didn't mean all the cache. I meant make user download the page next time he goes back to it (by pressing back button in my case).

Edit Usually Sky Sanders suggestion works. In fact that what I tried right away, but even though it worked for simple page it failed when putting Response.Redirect after cache headers. Even though FF received headers it still provided me with a cached page when I pressed back button.

Upvotes: 3

Views: 683

Answers (2)

Sky Sanders
Sky Sanders

Reputation: 37104

The only way you can control caching from the content end of the stick is to prevent caching in the first place.

context.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.Cache.SetNoStore();

You cannot invoke methods on the client browser.

Upvotes: 3

marcgg
marcgg

Reputation: 66485

No, you can't clear the browser cache from your web app. You could clear the cookies but that's about it.

Upvotes: 2

Related Questions