Skip to content

Workers Cache

部署配置驱动的 HTTP 响应缓存,以及租户 Cache API。

json
{
  "name": "cached",
  "main": "src/index.ts",
  "cache": { "enabled": true, "cross_version_cache": false },
  "exports": {
    "Admin": { "type": "worker", "cache": { "enabled": false } }
  }
}

cache.enabled 打开默认 HTTP cache。cross_version_cache 允许跨部署版本共享;默认隔离。exports.<name> 只能覆盖具名 Worker entrypoint 的缓存策略。自动缓存需要显式 s-maxagemax-age

Cache API(caches.default / caches.open)见 Runtime APIs · Cache

兼容性

主题Cloudflareopen-compute
cache.enabled、entrypoint override、cross_version_cache是,见 Workers Cache configuration配置形状对齐
Cache API 符号是,见 Cache API
缓存在哪全球 / colo本机
自动缓存 TTL可含启发式 TTL需要显式 s-maxagemax-age;无启发式 TTL
全球复制 / purge 传播 / tiered cache / Cache Rules / Cache Deception Armor / 套餐相关行为不提供
对象大小配额Cloudflare 产品配额默认每个缓存对象 16 MiB、每个 Worker 1 GiB 逻辑 body 字节;精确值由 ocd capabilities --json 给出