Skip to content

Limits

Script limits

Cloudflare provides an unlimited number of scripts for Workers for Platforms customers.

cf object

The cf object contains Cloudflare-specific properties of a request. This field is not accessible in user Workers by default because some fields in this object are sensitive and can be used to manipulate Cloudflare features (for example, cacheKey, resolveOverride, scrapeShield).

In the default untrusted mode, this also applies to outgoing requests. Any cf properties a user Worker sets on a fetch() subrequest are ignored, and the subrequest uses the default cache behavior for its URL.

This includes the standard cache option of fetch() and Request. Workers implement cache: "no-store" and cache: "no-cache" as cf cache settings, so in untrusted mode they do not change how the subrequest is cached:

// In a user Worker in an untrusted dispatch namespace:
await fetch("https://example.com/file.bin", {
	method: "HEAD",
	cache: "no-store",
});
// The cache is not bypassed. Because .bin is a default cached file extension,
// the request goes through the cache and reaches the origin as a GET.

The Cache-Control: no-cache and Pragma: no-cache request headers that these options add are still sent to the origin. They do not affect whether Cloudflare's cache handles the request.

When a subrequest goes through the cache, HEAD requests can be sent to the origin as GET, and the Range header can be removed. For more information, refer to Interaction of HEAD requests with Cache and Range request behavior.

To use cf properties or the cache option for requests from user Workers, use one of these options:

  • Trusted mode: Enable trusted mode for your namespace. Only enable this if you control all Worker code in the namespace.
  • Outbound Worker: Set the cache options in an Outbound Worker, which runs as your platform's Worker rather than the user Worker. When an Outbound Worker is enabled, user Workers cannot use connect(), except through Hyperdrive bindings.
  • Service binding: Give user Workers a service binding to a Worker you own outside the namespace, in the same account. User code sends the requests that need the cache option through the binding. User Workers keep connect().

A Worker outside the namespace runs as your platform's code, so the cache option on its own fetch() takes effect. The cf object of the user Worker is not passed to it, so user code cannot use it to set other cf properties:

// A Worker outside the dispatch namespace. User Workers have a service binding
// to it named PLATFORM_FETCH. The cache option needs a compatibility date of
// 2024-11-11 or later.
export default {
	fetch(request) {
		return fetch(new Request(request, { cache: "no-store", cf: {} }));
	},
};
// In a user Worker:
await env.PLATFORM_FETCH.fetch("https://example.com/file.bin", {
	method: "HEAD",
});
// The cache is bypassed, and the origin receives a HEAD request.

Use cache: "no-store" rather than cache: "no-cache". no-cache only asks the cache to revalidate, so HEAD requests can still be sent to the origin as GET.

Any user Worker with the binding can use this Worker to send requests that bypass the cache. To keep it limited to that:

  • Do not add routes to this Worker, and turn off its workers.dev and Preview URLs, so that only user Workers with the binding can call it.
  • Do not add secrets or authentication to the requests this Worker sends, and do not trust headers from the caller for authentication.
  • Do not let end users choose the targets of the service bindings in the user Workers you upload. Otherwise, user code could bind to your dispatch Worker or other platform Workers.
  • If this Worker needs to know which user Worker is calling it, pass that information in the binding's props.

Durable Object namespace limits

Workers for Platforms do not have a limit for the number of Durable Object namespaces.

Cache API

For isolation, caches.default is disabled for namespaced scripts. To learn more about the cache, refer to How the cache Works.

​Tags

You can set a maximum of eight tags per script. Avoid special characters like , and & when naming your tag.

Gradual Deployments

Gradual Deployments is not supported yet for user Workers. Changes made to user Workers create a new version that deployed all-at-once to 100% of traffic.

API Rate Limits

Type Limit
Client API per user/account token 1200/5 minutes
Client API per IP 200/second
GraphQL Varies by query cost. Max 320/5 min
User API tokens per user 50
Account API tokens per account 500

Some specific API calls have their own limits and are documented separately, such as the following:

Enterprise customers can also contact Cloudflare Support to raise the Client API per user, GraphQL, or API token limits to a higher value.

Was this helpful?