Expand description
Cloudflare-purge backend for crate::cache_invalidate::PageCacheInvalidator.
Wires the per-page cache-invalidation hook to Cloudflare’s purge_cache API. After a CMS save, the public URL is dropped from Cloudflare’s edge cache so the next request regenerates against the freshly-saved markup instead of waiting for the cache TTL to elapse.
§Usage
Behind the cache_cloudflare feature. Two args:
ⓘ
use rustango_cms::cache_cloudflare::CloudflareInvalidator;
let inv = CloudflareInvalidator::new(
std::env::var("CLOUDFLARE_ZONE_ID").unwrap(),
std::env::var("CLOUDFLARE_API_TOKEN").unwrap(),
)
.with_origin_host("acme.example.com");
let router = rustango_cms::admin::router_with_invalidator(
tera.clone(),
std::sync::Arc::new(inv),
);The token needs Zone:Cache Purge:Edit on the target zone —
token-permissions. Failures are logged through tracing
at WARN; the calling admin handler doesn’t propagate the error
(cache-invalidation is best-effort by trait contract).
Structs§
- Cloudflare
Invalidator - Build absolute URLs the public router is serving by joining the
tenant’s public host with the supplied url_path. Cloudflare’s
purge API accepts full URLs (
https://example.com/about/) and drops the matching edge entry on every PoP. Per-tenant deploys typically map one tenant to one origin host; multi-host setups can register the additional hosts viaCloudflareInvalidator::with_tenant_host.