Workers can now force cache revalidation with cache: no-cache
Cloudflare Workers now support the cache: "no-cache" property on Request objects, allowing subrequests to force revalidation of cached content with the origin. This improves compatibility with NPM packages and JavaScript frameworks that rely on the standard Request interface cache property.
By setting the value of the cache property to no-cache, you can force Cloudflare's
cache to revalidate its contents with the origin when
making subrequests from Cloudflare Workers.
export default {
async fetch(req, env, ctx) {
const request = new Request("https://cloudflare.com", {
cache: "no-cache",
});
const response = await fetch(request);
return response;
},
};index.tstsexport default {
async fetch(req, env, ctx): Promise<Response> {
const request = new Request("https://cloudflare.com", { cache: 'no-cache'});
const response = await fetch(request);
return response;
}
} satisfies ExportedHandler<Environment>
When no-cache is set, the Worker request will first look for a match in Cloudflare's cache, then:
- If there is a match, a conditional request is sent to the origin, regardless of whether or not the match is fresh or stale. If the resource has not changed, the cached version is returned. If the resource has changed, it will be downloaded from the origin, updated in the cache, and returned.
- If there is no match, Workers will make a standard request to the origin and cache the response.
This increases compatibility with NPM packages and JavaScript frameworks that rely on setting the
cache property, which is a cross-platform standard part
of the Request interface. Previously, if you set the cache
property on Request to 'no-cache', the Workers runtime threw an exception.
- Learn how the Cache works with Cloudflare Workers
- Enable Node.js compatibility for your Cloudflare Worker
- Explore Runtime APIs and Bindings available in Cloudflare Workers
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Cloudflare One Client for macOS 2026.8.2100.0
GA release for macOS Cloudflare One Client with improved split tunnel handling that no longer briefly blocks traffic during reconnects, support for non-RFC 1918 local IPv4 networks, faster connects with lower memory use, and numerous reliability fixes across DNS, reauthentication, and client stability.
Cloudflare One Client for Windows 2026.8.2100.0
This GA release improves split tunnel reliability, adds support for non-RFC 1918 local networks, optimizes connection performance with faster reconnections and lower memory usage, and includes numerous bug fixes for DNS, registration, and network handling. The client now features a service recovery mechanism that automatically restarts on system unlock and better handles large hosts files without blocking traffic.
Cloudflare One Client for Linux 2026.8.2100.0
New GA release for Linux with improved split tunnel handling that no longer briefly blocks traffic during reconnects, support for non-RFC 1918 local IPv4 networks, faster tunnel reconnections, and lower memory usage. Includes numerous stability and reliability fixes for DNS, reconnection behavior, and crash issues.