Ability to store snapshots to memory instead of sessionStorage
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
I'm about to build an SPA-only site, and currently evaluating what choices I have for my requirements and use cases in mind, and one of my requirements is as follows:
Is there a way to cache the page data from the universal load function, but only cache it for back/forward navigation only? I would like to have it load fresh data if users does a push to navigation stack. SWR isn't very ideal because for what I'm doing, it results in very jank behaviors with items jumping around.
Now, the back and forward caching might just be solved by #9822, and that's great! However, my payloads can be very large and I'd be limited to just primitive values, which is something I can remediate but would result in some very messy logic, so it'd be great if I can just instantiate classes directly within the page data, especially if it's an SPA-only site I'm working with.
Another thing to consider, is that if my snapshots are persisted to sessionStorage, what happens if I reload? What people normally expects out of a reload is all the states are blanked, fresh data gets loaded, and that should apply to snapshots too, especially for snapshots that aren't about scrolling or forms.
Describe the proposed solution
A way to have snapshots that aren't bound to sessionStorage would be nice for this,
export const snapshot = {
type: 'memory',
capture () {
// ...
},
restore () {
// ...
},
};
Alternatives considered
One way to go about this would be storing the temporary data on IndexedDB, but it's not very ideal, having to store what is essentially temporary data on a permanent storage, not to mention it still has to be primitive values
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the snapshot behavior described here and compare it with the back/forward caching work in #9822, focusing on the current sessionStorage assumptions. Done means defining and implementing a memory-backed snapshot option that supports the proposed capture and restore hooks and is cleared on reload.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100