[wp-trac] [WordPress Trac] #63636: Enable instant page navigations from browser history via bfcache when sending "nocache" headers
WordPress Trac
noreply at wordpress.org
Fri Sep 19 00:02:53 UTC 2025
#63636: Enable instant page navigations from browser history via bfcache when
sending "nocache" headers
-------------------------------------------------+-------------------------
Reporter: westonruter | Owner:
| westonruter
Type: enhancement | Status: accepted
Priority: normal | Milestone: 6.9
Component: Administration | Version: 6.3
Severity: normal | Resolution:
Keywords: has-patch dev-feedback needs-unit- | Focuses:
tests | performance, privacy
-------------------------------------------------+-------------------------
Comment (by westonruter):
Ideally the `pageshow` event wouldn't need to be relied on to use JS to
invalidate pages from bfcache. While this works, it is somewhat of a hack,
and there remains a possible split-millisecond in which a previously-
authenticated page can appear prior to the `pageshow` event handler
detecting the authentication state change and triggering a reload.
There's also an [https://github.com/westonruter/nocache-bfcache/issues/53
issue] I discovered when using a service worker to serve pages with a
NetworkFirst strategy, where a page gets served from cache if the network
doesn't respond before a timeout occurs. This can result in pages stored
in Cache by the service worker which have stale bfcache session token, and
then every navigation which returns such a page in cache will immediately
reload once served from cache. Not ideal.
The correct solution to protecting privacy is invaliding pages from
bfcache using the `Clear-Site-Data: "cache"` response header, as
[comment:4 mentioned above]. The benefit here is that there is no
JavaScript involved at all. See also the [https://github.com/westonruter
/nocache-bfcache/issues/22 feature plugin issue] I created for this.
This header is [https://caniuse.com/mdn-http_headers_clear-site-data_cache
well supported] by browsers. ''However'', there is currently a bug in
Chromium ([https://issues.chromium.org/issues/40233601 40233601]) which
causes page responses sent with this header to be very slow. I think this
should be a blocker preventing this from moving forward until it is fixed.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63636#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list