-
Notifications
You must be signed in to change notification settings - Fork 385
Add ability to opt-out of back-forward cache #1917
Copy link
Copy link
Open
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interest
Description
What problem are you trying to solve?
Users sometimes use back navigation to reach previous pages, when the portions of the page state loaded via fetch have been updated since their previous navigation. The result is a page with stale data, especially for SSR web applications with some dynamic content, where the full page itself is usually cached.
Lots of fetch requests should be cached, but should not be pulled from previously cached versions on back navigation, e.g. a user's cart. Being able to provide a hint to the fetch API/browser that a fetch request should not be bf-cached would be very helpful.
What solutions exist today?
- You can set cache-control headers, but most browsers seem to ignore these when using bfcache
- You can set
cache: 'no-store'on the fetch request, but Safari definitely ignores this when using bfcache, and it can result in never caching a response when that's not the optimal behavior in many cases - You can listen to the pageshow event and check if the page was persisted, and trigger your API request, but you have to do this manually for every request you want to re-run
How would you solve it?
I would add an additional bfcache property to the request init object, with values like 'no-store'.
Anything else?
See this related issue:
whatwg/html#5744
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interest