Back Navigation Pulls from Stale Cache
Summary
Navigating a browser backwards through GitLab pages pulls copies of pages when they were first loaded. This causes any page state that was altered by ajax requests or polling to be missing (and won't update automatically).
Steps to reproduce
- Go to a page on GitLab that gets ajax updates (issue / MR)
- Wait for something on the page to change (or add a comment from a different tab)
- Click a link to an internal GitLab page
- Navigate your browser back to the previous page.
Expected behavior
- Load the content of the page when it was last seen (standard browser behavior)
- Update the page with the latest content
Actual behaviour
- Load the contents of the page from when it was first loaded (turbolinks cache)
- The page does not automatically update
Possible fixes
Two solutions:
Set the cache to 0 so that no pages are cached using HTML5 History.
Turbolinks.pagesCached(0);
Another solution is to listen to "page:restore" event and call your initialization method. This latter solution is more performant.
document.addEventListener("page:restore", function() { app.init(); });
I suspect there may be alternative solutions, but these are the basic building blocks.
It might be possible to update the turbolinks cache after each ajax request and request a page update on "page:restore" events.