-
Notifications
You must be signed in to change notification settings - Fork 842
Discontinue sending redundant Cache-Control: no-store in admin to prevent breaking bfcache
#44322
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
Discontinue sending redundant Cache-Control: no-store in admin to prevent breaking bfcache
#44322
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
jeherve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Do you think you could add changelog entries for the 2 projects touched by this PR? You should be able to run jetpack changelog add to get started with that.
Thank you.
Co-authored-by: Jeremy Herve <[email protected]>
@jeherve Who would be able to fix the Akismet screen to remove the deprecated |
I've let someone on our team know about this, they'll look into it and get back to us! |
I've just pushed a fix that makes the two Akismet settings pages that use iframes eligible for the bfcache, as confirmed by Chrome's dev tools. |
Proposed changes:
First of all, this prevents Jetpack from sending redundant "nocache" headers which are already being sent by
nocache_headers(). Theno-storedirective was added by default as of WordPress 6.3 via Core-21938, and Jetpack now requires WP 6.7. This removes/deprecates code introduced in #9010 and #23146. The redundancy can be seen by looking at the duplicatedno-storein theCache-Controlresponse header:Cache-Control: no-cache, must-revalidate, max-age=0, no-store, private, no-storeSecondly, this PR allows plugins to omit the
no-storedirective to prevent breaking bfcache (back/forward cache) to enable instant history navigations. Plugins can do this via thenocache_headersfilter in core. For example, I've been working on No-cache BFCache plugin which allows a user to opt in to bfcache by checking the "Remember Me" checkbox. This is a feature plugin for Core-63636 (Enable instant page navigations from browser history via bfcache when sending "nocache" headers) which I hope to land in WP 6.9. However, when Jetpack is active this is blocked due to theno-storewhich it adds. See the Web.dev bfcache article section on minimizing use ofCache-Control: no-store.Demo Videos
Compare navigating back/forward without bfcache and with bfcache, in the first video without bfcache I try navigating back and forward as soon as the page fully loads. In the second video with bfcache, navigation back and forward is instant and because of that the network log shows as empty, and I end the video with trying to go back and forward as fast as I possibly can to show how instant the page load is:
sans-bfcache.mov
with-bfcache.mov
See also woocommerce/woocommerce#58445 for a similar removal of
no-storefrom WooCommerce and a demo video of how this can improve the user's browsing experience. If the original desire for introducingno-storewas to ensure that the no stale data is shown on the Jetpack settings screens, then the better way to achieve this is to add apageshowevent handler that checks the event object'spersistedproperty to see if it is true, and in that case fetch the latest data. WooCommerce is already doing this to ensure the cart data is as fresh as possible when pages are restored from bfcache.Aside 1: In Chrome, the WebSocket opened by the Notifications module currently also disables bfcache. However, this won't break bfcache in a future version of Chrome according to DevTools. In the meantime, bfcache can be enabled in the admin when Jetpack is active by deactivating the Notifications moule in Jetpack settings (on
/wp-admin/admin.php?page=jetpack_modules) and by having this PR applied which removesCache-Control: no-store.Aside 2: The Akismet screen breaks bfcache due to an
unloadevent listener served from anframeathttps://tools.akismet.com/1.0/snapshot.php. Theunloadevent should never be used. Its use was removed from WordPress in Core-55491 for WP 6.4, so it should be removed from the Akismet service as well.Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Cache-Control: no-storeis still being sent as expected.Closes HOG-232