arlen
arlen

Reputation: 1065

How to refresh page when hitting back button on browser (IE,Chrome,Firefox Safari)?

Most browsers reload the page from cache and do not perform a round trip server refresh. I added Response.AppendHeader("Cache-Control", "no-store") on Page_Load but not working for Chrome, Firefox, Safari. How to refresh page when hitting back button on browser (IE,Chrome,Firefox Safari) ?

Upvotes: 5

Views: 7207

Answers (2)

abney317
abney317

Reputation: 8502

This would be for your c# code I'm assuming. These are my suggestions in order of most suggested to least.

Response.Cache.SetNoStore();

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.AppendHeader("pragma","no-cache");

Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));

Upvotes: 5

Rag
Rag

Reputation: 6603

It's probably a bad idea to force this behavior because the user is expecting to see what they saw before, not a refreshed view. If that's the behavior of Chrome/Firefox/Safari then presumably the users desire this behavior because they chose that browser. If they want a refreshed view, they can refresh on their own.

That said, I often see this done with Javascript in the browser. You can hook into page load events and manually refresh if you see the page being loaded a second time. But if the client uses noscript, or otherwise doesn't support Javascript, then you're out of luck. Also, be careful to reload correctly so that users don't get taken to a new page every time they click Back and get stuck in a battle of fast-clicking reflexes.

Upvotes: 2

Related Questions