Cache middleware with types
fetch
handler.Otherwise you can use this:swr
method, that acts as a pull through cache. If the data is fresh, it will be returned from the cache, if it’s stale it will be returned from the cache and a background refresh will be triggered and if it’s not in the cache, the data will be synchronously fetched from the origin.
.get(key)
swr
works with tiered caches, but for simplicity, these charts may only show a single store.
DefaultStatefulContext
:
Store
interface.
Read more.Map
is instantiated in a persistent scope of your application. For Cloudflare workers or serverless functions in general, this is the global scope.
Cache
API to store cache values. This is a remote cache that is shared across all instances of your worker but isolated per datacenter. It’s still pretty fast, but needs a network request to access the cache.
Cache Purge
permission. You can create a new API token with this permission in the Cloudflare dashboard.zoneId
.domain: "cache.unkey.dev"
in our API.cacheBuster
value. The cacheBuster
is used as part of the cache key and changes ensure you are not reading old data anymore.Metrics
interface.
For example we are using axiom.
EncryptedStore
.
All you need is a 32 byte base64 encoded key.
You can generate one with openssl:
AES-256-GCM
and persisted in the underlying store.