Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I clear browser cache of the page leaving page?

Tags:

html

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.

like image 540
Sergej Andrejev Avatar asked Nov 22 '25 05:11

Sergej Andrejev


2 Answers

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.

like image 185
Sky Sanders Avatar answered Nov 23 '25 21:11

Sky Sanders


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

like image 21
marcgg Avatar answered Nov 23 '25 20:11

marcgg