Skip to content

Conversation

@westonruter
Copy link
Contributor

@westonruter westonruter commented Jul 16, 2025

Proposed changes:

First of all, this prevents Jetpack from sending redundant "nocache" headers which are already being sent by nocache_headers(). The no-store directive 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 duplicated no-store in the Cache-Control response header:

Cache-Control: no-cache, must-revalidate, max-age=0, no-store, private, no-store

Secondly, this PR allows plugins to omit the no-store directive to prevent breaking bfcache (back/forward cache) to enable instant history navigations. Plugins can do this via the nocache_headers filter 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 the no-store which it adds. See the Web.dev bfcache article section on minimizing use of Cache-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:

Without bfcache With bfcache
sans-bfcache.mov
with-bfcache.mov

See also woocommerce/woocommerce#58445 for a similar removal of no-store from WooCommerce and a demo video of how this can improve the user's browsing experience. If the original desire for introducing no-store was to ensure that the no stale data is shown on the Jetpack settings screens, then the better way to achieve this is to add a pageshow event handler that checks the event object's persisted property 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 removes Cache-Control: no-store.

Screenshot 2025-07-15 at 16 42 59

Aside 2: The Akismet screen breaks bfcache due to an unload event listener served from an frame at https://tools.akismet.com/1.0/snapshot.php. The unload event 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:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

  1. Navigate to the Jetpack screens and ensure that Cache-Control: no-store is still being sent as expected.

Closes HOG-232

@github-actions github-actions bot added [Package] My Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jul 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 16, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: August 5, 2025
    • Code freeze: August 4, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. OSS Citizen This Pull Request was opened by an Open Source contributor. labels Jul 16, 2025
@jeherve jeherve requested a review from a team July 16, 2025 09:16
@jeherve jeherve added [Focus] Performance [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. [Pri] Low and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 16, 2025
@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Jul 16, 2025
Copy link
Member

@jeherve jeherve left a 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.

@westonruter
Copy link
Contributor Author

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.

@jeherve Added via 693f5d4

@jeherve jeherve added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 17, 2025
@jeherve
Copy link
Member

jeherve commented Jul 17, 2025

@jeherve Added via 693f5d4

Thank you!

@westonruter
Copy link
Contributor Author

Aside 2: The Akismet screen breaks bfcache due to an unload event listener served from an frame at https://tools.akismet.com/1.0/snapshot.php. The unload event 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.

@jeherve Who would be able to fix the Akismet screen to remove the deprecated unload event?

@jeherve
Copy link
Member

jeherve commented Jul 17, 2025

Who would be able to fix the Akismet screen to remove the deprecated unload event?

I've let someone on our team know about this, they'll look into it and get back to us!

@cfinke
Copy link
Contributor

cfinke commented Jul 22, 2025

Aside 2: The Akismet screen breaks bfcache due to an unload event listener served from an frame at https://tools.akismet.com/1.0/snapshot.php. The unload event 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.

@jeherve Who would be able to fix the Akismet screen to remove the deprecated unload event?

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.

@kraftbj kraftbj self-requested a review July 29, 2025 14:53
@kraftbj kraftbj self-assigned this Jul 29, 2025
@kraftbj kraftbj merged commit 4b1acd1 into Automattic:trunk Jul 29, 2025
60 of 62 checks passed
@github-actions github-actions bot added this to the jetpack/14.9 milestone Jul 29, 2025
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Performance OSS Citizen This Pull Request was opened by an Open Source contributor. [Package] My Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Low [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants