blob: 21ea7a217465218eeda2d3ec4b882c8f76983553 [file] [log] [blame] [view]
Fergal Daly7f6429702024-12-11 05:30:311# BFCache Overview
2
3## TL;DR
4
5Without back/forward-cache (BFCache),
6when the browser navigates away from a page,
7it discards the DOM and all of the JS context.
8If it returns to that page,
9even if every resource is served from the HTTP cache,
10it has to parse everything from scratch
11and execute the JS in a fresh JS context.
12With BFCache,
13when the browser navigates away from a page,
14it might just pause that page,
15keeping everything fully intact.
16If it returns to that page,
17it can simply unpause it,
18giving the user a much fast user-experience.
19
20## Contact
21
22Please reach out to [bfcache-dev@chromium.org](mailto:bfcache-dev@chromium.org) for advice.
23
24## Your feature and BFCache
25
26Ignoring BFCache can result in serious privacy problems.
27The performance benefit provided by BFCache are enormous.
28As a result,
29it is not acceptable to launch a feature
30and figure out BFCache later.
31TAG, privacy and API owners
32are all be on the look-out for APIs
33that have not properly considered BFCache.
34
35There are many pre-existing features that are not compatible with BFCache.
36Some are fundamentally incompatible given their current API/UX.
37Some are potentially compatible
38but predate BFCache in Chrome.
39We have ensured that BFCache is disabled
40when these features are active.
41This avoids privacy problems
42at the expense of performance.
43We do not want to add to this list.
44
45### Specs
46
47If your feature is part of the web platform,
48you should ensure that BFCache
49(and other non-fully-active states like prerendering)
50are accounted for in the spec.
51
52The two main docs you need to read are
53- https://www.w3.org/TR/design-principles/#support-non-fully-active
54- https://w3ctag.github.io/bfcache-guide/
55
56These are essential reading for all new WP features.
57The privacy and security questionnaire for TAG review
58contains a section on non-fully-active behaviour.
59Chrome's privacy team also requires
60specific consideration of BFCache
61(and other non-fully-active documents)
62during privacy reviews.
63
64### Implementation
65
66Even if your feature is only a part of the browser,
67you may still need to worry about BFCache.
68If your feature interacts with pages
69or reacts to page events or navigation
70then it may need logic to cope with the fact that
71pages are not necessarily destroyed
72when navigation occurs
73(an assumption that was correct for decades).
74
75[This doc](https://docs.google.com/document/d/1kR9QHWXXpoXsP3Y6JEDpIgZ5p7EgTTvdDN2kIrYdXcg/edit?tab=t.0#heading=h.b5k2sf3jhu99)
76provides advice on how to make a feature behave nicely with BFCache.
77Please also [contact us](mailto:bfcache-dev@chromium.org)
78for explainer, design or code reviews.