To test this, you can: 1) go to the all compatible layers page 2) add the meta-ettus layer (that will bring in meta-oe too) 3) in the notification at the top of the page, click on 'meta-ettus' 4) click the back button to go back to the all layers page. meta-ettus and meta-oe no longer show the 'delete layer' buttons, but the 'add layer' ones. If you refresh the page, the page shows the correct buttons. The problem happens at least in all the 'all compatible' pages and the layer details pages.
What we need to do is if the ctx data for the page has changed then replace the browser's history state with the ctx data e.g. window.history.replaceState(ctx, "toaster", window.location.pathname) Then connect the window.onpopstate to reload the ctx unfortunately knowing when the ctx var has changed isn't that simple as we don't have observe() methods across all browsers yet and we can't put a reference into the browser. We either need to manually trigger the replace state or abstract it so that setting properties on the ctx object happens with a call to replaceState.
Elliot do you have any ideas on how this issue is normally solved? It's basically when the JS has modified the DOM and you press back and forward in the browser and the browser loads it's cache which doesn't take into account the modifications.
The blanket approach would be to use cache control headers in the responses to force the page to be fetched from the server each time it's requested, as described in http://blog.ionelmc.ro/2011/03/17/stale-formsets-and-the-back-button/ ("no-store" in particular). However, this impacts performance, as a page is freshly requested every time a user goes to it. But for Toaster, where data is changing all the time anyway, it should prevent stale data appearing, so the hit might be worth it. Alternatively, there are much more subtle things we could do, as you suggested, like pushing state into the history. This gives finer grained control, as we can invalidate the cache for individual pages (in effect), but it's far more complicated. There may also be ways to accomplish this in Django, but I've not investigated how we're using caching yet.
Submitted to toaster mailing list for review.
Need to modify the branch as per Michael's comments of 2015-09-30: "If we replace state each time we load, we won't have a back stack to put the tableData into and subsequently pop it out of on the onpopstate event, could you also remove storing the tableData, tableParams in the browser and remove the window.onpopstate handler code as that won't ever fire now."
This is not in bitbake master, so isn't fixed.
Now in poky (bitbake) master, closing.
Verified on master: 505a82673ac2487df5ea343a6422c2fc47018831