-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Back-forward cache: Specifying ineligibility? #5879
Comments
In general, we don't want to limit the eligibility of page cache because we want to expand it as much as possible for better user experience. @cdumez |
Indeed, this is the case. Note also that the spec currently has a salvagable state, which if you follow the links around, is used to basically disable bfcache whenever unload handlers are triggered. From what I understand browsers are intentionally violating this part of the spec these days, and we should probably clean that up...
Although I tend to agree with @rniwa in the general case, I wonder about the case of explicit web developer opt-outs. #5744 has some discussion in that regard (although it went in a different direction). I wonder if at least
I'm not quite clear on what spec change you are proposing. Are you concretely suggesting, per the linked document, IndexedDB and Web Locks make pages bfcache-ineligible? If so, I think it'd be good to discuss those specifically, and get all the implementers' perspectives. |
Yeah I guess I'm mostly concerned about the specific case of For the explicit bfcache opt out discussed in #5744, it looks like the direction the API is going towards currently is "remove currently-alive documents from history entries", so we can spec that without this. For APIs like IndexedDB, I was thinking that if we already have a concept of "bfcache ineligibility", then we can add a handwavy note like "If the page has existing connections/relations that might affect other pages, such as an IndexedDB connection, the user agent might consider the page as ineligible for bfcache" . But maybe that won't really make sense/won't really help? Maybe as Domenic mentioned it's better to talk about each API separately and clarify how they would work (or not) when bfcached.. |
Makes sense. I take it that Chrome plans to, for the foreseeable future, treat this as an opt-out for bfcache, and would support writing that opt-out into the spec? I'm curious to hear from Safari and Firefox in that case; if it's something everyone agrees on, we could at least make it a "should", if not a "must".
I think it makes sense, but indeed, it only helps a minimal amount. Since the UA gets to do whatever it wants, adding such spec text wouldn't improve interop or provide strong guidance for browsers to rally around. Instead it would just make the spec a bit more understandable, whereas right now it's a mystery as to why a browser would or would not put things in bfcache. Increasing understandability in this way is a reasonable goal, and I would be fine reviewing/merging PRs of that sort. But I think the higher impact would be from specifying how things work when bfcached. |
@rakina's changes in #5889 made me realize the spec already prohibits bfcaching in some cases (via the "salvagable" mechanism): https://html.spec.whatwg.org/#dom-pagetransitionevent-persisted-dev has a non-normative list (which #5589 modifies). If folks think that list is too restrictive, we may want to spin off separate issues (e.g., if browsers want to figure out a way to bfcache pages with open WebSockets). Alternately, it serves as an easy place to expand, if we want to make |
Yeah I agree. On this topic, recently there's some interest in making things like WebRTC work with bfcache (no public threads yet though). To help spec this, I think we need to have "before-getting-bfcached cleanup steps" so that we can say that we're pausing connections etc. Do we have something like this already? If not maybe we can modify and reuse "unloading document cleanup steps" for this (this also helps remove one more usage of "unload" :) )
Right, so we have a way to specify ineligibility nicely, yay \o/ BTW, looks like we're summarizing cases where we modify the "salvageable" bit all over the spec in the note for the "persisted" bit. Perhaps we should move it somewhere closer to unload/"before-getting-bfcached cleanup steps" when we have that. (Also, on the WebSockets part specifically, I found #1931) |
Some questions
Based on https://github.com/httpwg/http-core/pull/545/files, it seems like it could be OK for BFCache to be used on a |
In issues like #7189 the Chrome team has started to make proposals for concrete behaviors. I'd like to get a sense from other implementers to what extent they are interested in interoperability and web platform predictability here, to figure out whether such concrete proposals should end up in the spec or in Chrome-specific documentation. In #5879 (comment) @rniwa says
which seems negative on this interop project. In general on the Chrome team, we'd prefer to have thorough specifications and tests for the behaviors we ship, including bfcache. But if there's not much appetite from the implementer community for that, that would be good to know. |
In WebKit/Safari, we leverage the back/forward cache almost unconditionally. Therefore, adding conditions for when a page is eligible for caching or not will decrease our cache hit. For example, I think Blink doesn't leverage the back/forward cache when a window has an opener but WebKit does. Aligning with Blink here seems like it would regress our perf. |
@cdumez there was a thread on exactly that case. What does WebKit do if the opener modifies the BFCached document? There does not seem to be any reasonable behaviour for that case (the document may have MutationObservers but they can't run). Even evicting in that case leaves the opener with a suddenly-null window reference. I realize that in many cases this will not happen, so you can get away with most of the time. |
As mentioned in #5744 and #5748, the factors that affect a page's eligibility to be preserved in BFCache differs between browsers, but some are consistent (e.g.
Cache-control: no-store
).I think the current spec allows "preserving"
Document
s implicitly by havingDocument
objects associated with session history entry, which will be used during history traversal.I wonder if it makes sense to specify that a
Document
should never be preserved/re-used on history traversal, or if that falls into "implementation details" territory? The spec change should be minimum, and with that we can remove a lot of ambiguity on "what should happen with this if theDocument
/browsing context associated with it is no longer active?" on some of the things that will make a page ineligible for bfcache (example).The text was updated successfully, but these errors were encountered: