Skip to content
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

Boost: Fix cache bypass patterns not applied from start of URL #40999

Merged
merged 20 commits into from
Jan 14, 2025

Conversation

dilirity
Copy link
Member

@dilirity dilirity commented Jan 13, 2025

@donnchawp raised a good point today. If you want to only exclude the page /test from the caching, according to the docs, you would do the following:

For instance, to exclude a shop page from being cached, simply input “/shop” (without the quotes). Place each path on its own line. If you need to exclude multiple pages under a single directory, you can use the wildcard symbol (.*) in your path. This might look like /blog/(.*) to exclude all pages under the “blog” section. 

However, if you do this, you will also exclude anything that contains /test in the url. So for example, you would prevent this URL from being cached: /2025/01/01/test/. This is because the current implementation of bypass pattern matching in Boost is very loose.

Proposed changes:

  • Make bypass pattern matching stricter to avoid disabling cache unintentionally;
  • Fix possible duplicates in bypass patterns list.

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

p1736763366014999-slack-C016BBAFHHS

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

n/a

Testing instructions:

  • Make sure you're using pretty permalinks for both tests.
  • Note, that if a page/post is excluded from cache, it doesn't have the cache header x-jetpack-boost-cache present. Only cacheable posts/pages have it (with a value of either miss or hit).

Test that exclusions don't behave as expected (old behavior)

  • Make sure you're using Boost 3.7.0 (or trunk) when testing this;
  • Add a page with the slug test so the url contains /test;
  • Now add a post with the slug test so the url ends with /test;
  • Enable cache and make sure that both post and page are cached;
  • Add /test to the cache exclusion list;
  • The page should no longer be cached. However, if you check the post, it is also not cached.

Test that there can be duplicates in the cache exclusions

  • If you have /test in the list, add the full URL of the page after it and save;
  • You should end up with /test twice in the list.

Test that exclusions are handled properly (strict matching, new behavior)

  • Apply this PR;
  • Check the page - it should not be cached;
  • Check the post - it should be cached.

Test that there are no duplicates in the cache exclusions

  • Make sure you have /test in the list and that the list is saved;
  • Add the full URL of the page to it and save the list;
  • There should be only one reference to /test in the list.

@github-actions github-actions bot added [Boost Feature] Page Cache [Plugin] Boost A feature to speed up the site and improve performance. [Status] In Progress labels Jan 13, 2025
Copy link
Contributor

github-actions bot commented Jan 13, 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 a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Boost plugin:

  • Next scheduled release: none scheduled.

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

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jan 13, 2025
@dilirity dilirity added [Type] Bug When a feature is broken and / or not performing as intended and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 13, 2025
@dilirity dilirity added this to the boost/next milestone Jan 13, 2025
@dilirity dilirity self-assigned this Jan 13, 2025
@dilirity dilirity requested a review from a team January 13, 2025 16:04
@dilirity dilirity marked this pull request as ready for review January 13, 2025 16:04
haqadn
haqadn previously approved these changes Jan 13, 2025
Copy link
Contributor

@haqadn haqadn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@dilirity dilirity merged commit 06943fd into trunk Jan 14, 2025
63 checks passed
@dilirity dilirity deleted the fix/boost/cache-bypass-patterns branch January 14, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Boost Feature] Page Cache [Plugin] Boost A feature to speed up the site and improve performance. [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants