Cache
Ten cache domains with their own TTLs, in memory or in Cloudflare KV, each clearable on its own.
Every request that touches payments, email, storage or AI
reads the provider configuration from the admin config table. Those reads are cached per domain, with a TTL you
set at /admin/config/cache. You can clear each domain separately when you have changed
something and do not want to wait for its TTL to expire.
Before you begin
config.readto see the page,config.writeto change a TTL or clear a domain. See Roles and permissions.- Memory is the default. Cloudflare KV is available only when the runtime has a
CACHEbinding. Redis is listed with an unavailable reason and is not connected to the cache layer.
Set it up
Choose a backend
Memory caches inside one process. On Workers, each isolate caches separately, and on Node each container does. KV is shared across instances. Unavailable backends remain visible with a reason. The runtime falls back to process memory if a configured backend is unavailable.
Set a TTL per domain
Each domain has its own default. With a short TTL on configuration, a provider change takes effect quickly. With a longer TTL on templates, content that rarely changes is read less often.
The save form accepts 1–86,400 seconds. Turn off Enabled to bypass caching for that domain. The TTL is retained for later use.
Clear a domain after a change
Saving a provider from /admin/config/* clears that domain, so your change takes effect
without waiting for the TTL. Clear a domain by hand when you changed a row
outside the console.
Domains and their defaults
| Domain | What it holds | Default TTL |
|---|---|---|
admin_config | The admin config table itself | 30s |
auth_config | Auth providers and options | 30s |
email_config | Email provider settings | 30s |
email_template | Rendered email templates | 60s |
payment_config | Payment provider settings | 30s |
storage_config | Object storage settings | 30s |
analytics_config | Analytics provider settings | 30s |
newsletter_config | Newsletter provider settings | 30s |
ai_channel_snapshot | The channel list | 30s |
ai_channel_resolved | Scene → channel resolution | 15s |
admin_config is the bootstrap domain. Every other domain reads its own policy through it, so
it cannot read its policy from the table it caches. Its TTL comes from
ADMIN_CONFIG_CACHE_TTL_MS, one of the few environment variables this project reads.
Policy
Prop
Type
To add another cache domain, update cacheDomains in cache-policy.ts. The admin page then shows its TTL setting and clear action.
Verify
- Open
/admin/config/cache. Ten domains are listed with their TTLs. - Change a payment setting at
/admin/config/payment, then load a checkout. The new setting is in effect immediately, without the 30-second wait. - Turn off Enabled for
email_templateand save. Template reads stop being cached. - On a runtime without the
CACHEbinding, the KV option is shown with the reason it is unavailable.
Reference
- Configuration model: why settings live in the database
- Environment variables: including
ADMIN_CONFIG_CACHE_TTL_MS - Deployment: which bindings a runtime has
- Cloudflare KV: the shared backend