-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Background
Per adobe/helix-deploy-plugin-edge#77 and comment, @adobe/fetch should export a CacheOverride API that provides cross-platform cache control for both Fastly Compute and Cloudflare Workers.
Proposal
Export a CacheOverride class/object that:
- On Fastly: Uses native
fastly:cache-overridemodule - On Cloudflare: Maps to
cf.cacheTtl,cf.cacheKey,cf.cacheTtlByStatusoptions
Common Options
- Mode:
"none","pass","override" - TTL: Time-to-live in seconds
- SWR: Stale-while-revalidate (Fastly only, graceful degradation on Cloudflare)
- Cache Key: Custom cache key string
- Surrogate Key: For cache purging (Fastly only, maps to
cf.cacheTagson Cloudflare)
Usage
import { fetch, CacheOverride } from '@adobe/fetch';
const cacheOverride = new CacheOverride('override', {
ttl: 3600,
swr: 86400
});
const response = await fetch(url, { cacheOverride });Platform Mapping
| Feature | Fastly | Cloudflare |
|---|---|---|
| Mode: pass | cacheOverride mode |
cf.cacheTtl: 0 |
| TTL | ttl option |
cf.cacheTtl |
| SWR | swr option |
Not supported |
| Cache Key | cacheKey in CacheOverride |
cf.cacheKey |
| Surrogate Key | surrogateKey option |
cf.cacheTags |
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request