2

I have a very simple use-case: Page1 is a list. When clicking on a list item, user goes to Page2 where she can make changes to that item. When navigating back, Page1 should reflect the changes.

Note: Page1 and Page2 are different pages for the server (this website is not a single-page webapp).

Disabling cache doesn't seem to solve the issue. Setting the Cache-Control header to no-cache, no-store works in Firefox (page refreshed upon navigating back), but fails in IE 11, Chrome desktop, Opera desktop, Safari OS X and Safari iOS. Surprisingly, it works on Chrome Android on my device.

I doubt there is a way to have the page refreshed that way on all those browsers, but I'll ask just in case: Is it possible to have a page consistently reloaded on all major browsers when navigating back?

If the answer is no, then Javascript may come to the rescue? For example some event(s) that I can listen to, and which will be triggered when navigating back, something that would work on all major browsers.

Basically, any solution where I can have updated data in Page1 when navigating back.

Thanks for any help!

Edit: I tested the "unload" trick explained at Is there a cross-browser onload event when clicking the back button?, and it doesn't work in Safari on Mac (V7.0.4).

Community
  • 1
  • 1
Blackbird
  • 2,368
  • 4
  • 26
  • 41
  • maybe this helps? http://stackoverflow.com/questions/158319/cross-browser-onload-event-and-the-back-button?rq=1 – juvian Jun 19 '14 at 17:26
  • @juvian Thanks for that suggestion. I had vaguely tested, with no convincing result. Will test more seriously and update my question. – Blackbird Jun 19 '14 at 22:05
  • @juvian Tested and edited my question. As some others wrote as a comment on that answer, the trick doesn't work in some current browsers. – Blackbird Jun 19 '14 at 22:36
  • The better question is, why would the user **need** to hit the back button? It should be clear on Page2 what the next step is. Navigating back is just not user friendly. – beautifulcoder Jun 19 '14 at 23:09
  • 1
    @beautifulcoder I use the back button _all the time_ — rather than using a 'home' button to get 'back' to the app home by going forward (in browser history) to start a new task I drop-down the history and jump to where I want to be. It may be not-the-usual behavior, but an app should handle that. – Stephen P Jun 19 '14 at 23:24
  • Well, not sure as I do not have safari, but there seem to be several topics about this, but doubt there is a cross-browser solution unless you try to use plugins. Maybe try http://stackoverflow.com/questions/5257819/onpopstate-handler-ajax-back-button . Also, http://stackoverflow.com/questions/172957/detecting-back-button-hash-change-in-url?rq=1 – juvian Jun 20 '14 at 00:48
  • @juvian Both the popstate event and hash change are useful for navigation in the same document (i.e single-page websites). As mentioned in my question, my website uses a classic architecture (*Page1* and *Page2* are different documents) – Blackbird Jun 23 '14 at 08:18
  • @Blackbird Well, first you need to check if you are able to detect browse back button on Page 1 with some of those options or another. Then you can do some localstorage changing in Page1 and listen for that in Page2 : http://stackoverflow.com/questions/2236828/javascript-communication-between-tabs-windows-with-same-origin/12514384#12514384 – juvian Jun 23 '14 at 16:13

1 Answers1

0

Have you tried this in the HTML?

<META HTTP-EQUIV="Expires" CONTENT="-1">

Why dont you just Redirect to Page1 after the user commits his changes on Page2 so that the user doesnt even have to go back in Browser?

Khaine
  • 21
  • 4
  • thanks for your answer. Unfortunately, even with this header added, the page doesn't reload when navigating back on Safari OS X. – Blackbird Jun 27 '14 at 08:33