Bug 7660 - Toaster loads pages from cache, and sometimes you get an old state
Summary: Toaster loads pages from cache, and sometimes you get an old state
Status: VERIFIED FIXED
Alias: None
Product: Toaster
Classification: Build System, Metadata & Runtime
Component: toaster (show other bugs)
Version: 1.8
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.0
Assignee: Elliot Smith
QA Contact: Cristina Agurida
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-04-24 16:08 UTC by Belen Barros Pena
Modified: 2015-10-27 16:21 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Belen Barros Pena 2015-04-24 16:08:36 UTC
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.
Comment 1 Michael Wood 2015-05-08 13:39:26 UTC
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.
Comment 2 Michael Wood 2015-08-20 09:22:09 UTC
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.
Comment 3 Elliot Smith 2015-08-24 13:21:16 UTC
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.
Comment 4 Elliot Smith 2015-09-14 15:09:50 UTC
Submitted to toaster mailing list for review.
Comment 5 Elliot Smith 2015-09-30 07:05:48 UTC
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."
Comment 6 Elliot Smith 2015-10-12 13:34:25 UTC
This is not in bitbake master, so isn't fixed.
Comment 7 Elliot Smith 2015-10-13 08:41:00 UTC
Now in poky (bitbake) master, closing.
Comment 8 Cristina Agurida 2015-10-27 16:21:09 UTC
Verified on master: 505a82673ac2487df5ea343a6422c2fc47018831