Origin Range Requests Are Now Fully Controllable Through Cloudflare's Cache Rules API!
Hi everyone, I'm Shiichan! Today's news is a quieter but important Cloudflare caching update. You can now control exactly how Cloudflare fetches large files from your origin, straight from the API.
Cloudflare ChangelogWhat was announced?
Cloudflare's Changelog announced that the Rulesets API now supports controlling Origin Range Requests inside Cache Rules. Origin Range Requests is the mechanism Cloudflare uses to fetch large files from your origin in cache-aligned byte ranges. Cloudflare may even expand a client's Range request and issue several single-range requests to your origin.
The story so far
Until now, Origin Range Requests behavior was left entirely to Cloudflare's default logic, with no way to toggle it per traffic pattern through the API. With this update, the set_cache_settings action in Cache Rules gains a new origin_range_requests.mode parameter, which you can set to on, off, or default.
What changes
If your team manages cache configuration through the Rulesets API or Terraform, you no longer need to click around the dashboard to change this behavior. You can now define and version-control Origin Range Requests behavior per matched traffic pattern as code. For example, if your origin's implementation can't handle Range requests properly for a specific URL pattern, you can now express that requirement directly in your IaC pipeline.
Dive Deep
Here's a Cache Rule that turns off generated Origin Range Requests for all traffic:
{
"expression": "true",
"action": "set_cache_settings",
"action_parameters": {
"origin_range_requests": {
"mode": "off"
}
}
}
A few things worth keeping in mind:
- Origin Range Requests doesn't make otherwise ineligible content cacheable
- If your origin ignores the
Rangeheader and returns a full200 OK, Cloudflare can still use that response, but it has to download the entire file - Your origin needs to honor
Accept-Encoding: identityand return consistent, unencoded partial responses
In other words, this feature only pays off if your origin correctly supports Range requests in the first place.
Wrap-up
- The Rulesets API now supports controlling Origin Range Requests in Cache Rules
- Set
origin_range_requests.modetoon,off, ordefaultto manage this behavior from the API or your IaC pipeline - It only adjusts how already-cacheable content is fetched, not what's cacheable
- Your origin needs to handle Range requests correctly for this to work
This one's for infra folks managing Cloudflare cache configuration through Terraform or the API for large-file delivery!