Page MenuHomePhabricator

MobileFrontend should use sessionStorage for expandedSections
Open, MediumPublic

Description

MobileFrontend uses localStorage to keep track of expandedSections indefinitely. This causes localStorage to grow.

Ideally this should use session storage as this information is only really needed inside a session.

https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 19 2020, 5:40 PM
Krinkle added a comment.EditedMay 19 2020, 6:46 PM

Ideally this should use session storage as this information is only really needed inside a session.

It's unfortunate that the Web Platform calls this "session storage". A more accurate name (based on the documentation) would be "tab storage".

If the expanded section feature only needs to store information on a single page view (with perhaps the the extra persistence of backward/forward and "re-open closed tab" navigations that re-create that same page view in the same tab), then sessionStorage is great. If not, then you probably don't want that.

In a nut shell: sessionStorage is not like a session cookie. There is no equivalent to session cookies in HTML5 Storage.

This causes localStorage to grow.

Note that the quota for sessionStorage generally isn't different or larger. Why does it grow? What's the ideal max size? Can it be limited?

the expanded section feature only needs to store information on a single page view (with perhaps the the extra persistence of backward/forward and "re-open closed tab" navigations that re-create that same page view in the same tab), then sessionStorage is great. If not, then you probably don't wan that.

the purpose of the feature is solely to restore back button behavior - so if a user clicks a link in a section and returns to the page they find themselves in the same position.

Note that the quota for sessionStorage generally isn't different or larger. Why does it grow? What's the ideal max size? Can it be limited?

We could limit it yes, but given the purpose is only for sessions, I'm not sure if there are any advantages to let it grow. Right now if I visit an article and then visit it again 3 months later the sections will remain open. That doesn't seem useful and is also inaccurate given those sections may have rearranged.

Awesome. That's quite literally a perfect fit for sessionStorage.

Jdlrobson triaged this task as Medium priority.May 19 2020, 8:51 PM
Jdlrobson moved this task from Incoming to Triaged but Future on the Readers-Web-Backlog board.
Jdlrobson moved this task from Backlog to Team: web on the MobileFrontend board.Jul 24 2020, 2:37 AM