Skip to content

Conversation

@yj7o5
Copy link
Contributor

@yj7o5 yj7o5 commented Mar 19, 2025

Summary

Adding a new compatibility flags: request_cf_overrides_cache_rules. The Cache team has fixed a behavior in cache recently for workers scripts that make subrequests either via the Fetch where by the cache settings in the request.cf object specified given the precedence vs Cache Rules. Up until now, for example, if cacheTtl was specified in both the worker script and a cache rule was configured to modify cacheTtl for the requested resource, cache rules would override the cacheTtl specified in the request.cf object. However, with the upcoming change, we have updated Cache such if the above flags are enabled then settings specified in the request.cf object take precedence.

Documentation checklist

  • The documentation style guide has been adhered to.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.

@hyperlint-ai
Copy link
Contributor

hyperlint-ai bot commented Mar 19, 2025

Howdy and thanks for contributing to our repo. The Cloudflare team reviews new, external PRs within two (2) weeks. If it's been two weeks or longer without any movement, please tag the PR Assignees in a comment.

We review internal PRs within 1 week. If it's something urgent or has been sitting without a comment, start a thread in the Developer Docs space internally.


PR Change Summary

Added compatibility flags to enhance cache behavior for Fetch and Cache APIs, allowing settings in the request.cf object to take precedence over Cache Rules.

  • Introduced two new compatibility flags: request_cf_overrides_cache_rules and cache_api_request_cf_overrides_cache_rules.
  • Updated cache behavior to prioritize settings in the request.cf object over Cache Rules for subrequests.
  • Created documentation for the new flags, detailing their functionality and enabling conditions.

Added Files

  • src/content/compatibility-flags/cache-api-request-cf-overrides-cache-rules.md
  • src/content/compatibility-flags/request-cf-overrides-cache-rules.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@yj7o5 yj7o5 force-pushed the compatflags branch 2 times, most recently from 9cf6bee to 120fcf8 Compare March 24, 2025 20:04
disable_flag: "no_request_cf_overrides_cache_rules"
---

This flag fixes the behavior of cache when requesting assets via the Fetch API whereby the cache settings specified in the `request.cf` object is given precedence over any Cache Rules set.
Copy link
Contributor

@mikenomitch mikenomitch Apr 1, 2025

Choose a reason for hiding this comment

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

Suggested change
This flag fixes the behavior of cache when requesting assets via the Fetch API whereby the cache settings specified in the `request.cf` object is given precedence over any Cache Rules set.
This flag changes the behavior of cache when requesting assets via the [Fetch API](/workers/runtime-apis/fetch). Cache settings specified in the `request.cf` object, such as `cacheEverything` and `cacheTtl`, are now given precedence over any [Cache Rules]([/cache/how-to/cache-rules/) set.


This flag fixes the behavior of cache when requesting assets via the Fetch API whereby the cache settings specified in the `request.cf` object is given precedence over any Cache Rules set.

With the flag enabled - either by default after 2025-03-26 or by setting the `request_cf_overrides_cache_rules` flag - any cache related settings in a Worker's `request.cf` object such as (`cacheEverything`, `cacheTtl`, etc) will override any cache rules for the target asset in subrequest.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
With the flag enabled - either by default after 2025-03-26 or by setting the `request_cf_overrides_cache_rules` flag - any cache related settings in a Worker's `request.cf` object such as (`cacheEverything`, `cacheTtl`, etc) will override any cache rules for the target asset in subrequest.
This flag will be enabled by default for any compatibility date after 2025-03-26.

@mikenomitch
Copy link
Contributor

@yj7o5 - Added some suggestions but +1s so I'm not blocking.

Slightly more direct wording, some links, and combined two lines that were doing the same thing.

@kodster28 kodster28 enabled auto-merge (squash) April 2, 2025 16:49
auto-merge was automatically disabled April 2, 2025 16:52

Head branch was pushed to by a user without write access

@kodster28 kodster28 merged commit 37aa7cf into cloudflare:production Apr 2, 2025
6 checks passed
@workers-devprod workers-devprod added the contribution [Holopin] Recognizes a docs contribution, big or small label Apr 2, 2025
@holopin-bot
Copy link

holopin-bot bot commented Apr 2, 2025

Congratulations @yj7o5, the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cm90aaozs04520cjsd3gw0jy4

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

@yj7o5 yj7o5 deleted the compatflags branch April 2, 2025 19:36
RebeccaTamachiro pushed a commit that referenced this pull request Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution [Holopin] Recognizes a docs contribution, big or small size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants