Expand description
Azure CDN purge backend for
crate::cache_invalidate::PageCacheInvalidator.
Wires the per-page cache-invalidation hook to the Azure CDN endpoints purge management API. After a CMS save the public URL is dropped from the Azure edge so the next request regenerates against the freshly-saved markup instead of waiting for the TTL.
§Usage
Behind the cache_azure feature. The Azure Resource Manager API
authenticates with a short-lived Azure AD bearer token, so the
invalidator takes an AccessTokenSource (use StaticToken
for scripts/tests; implement the trait against your managed-identity
/ az account get-access-token endpoint for a long-running server):
use std::sync::Arc;
use rustango_cms::cache_azure::AzureCdnInvalidator;
use rustango_cms::cache_invalidate::StaticToken;
let inv = AzureCdnInvalidator::new(
"00000000-0000-0000-0000-000000000000", // subscription id
"my-rg", // resource group
"my-cdn-profile", // profile
"my-endpoint", // endpoint
Arc::new(StaticToken(std::env::var("AZURE_ACCESS_TOKEN").unwrap())),
);
let router = rustango_cms::admin::router_with_invalidator(
tera.clone(),
Arc::new(inv),
);The token’s principal needs Microsoft.Cdn/profiles/endpoints/purge/action
on the endpoint. Failures are logged through tracing at WARN; the
calling admin handler doesn’t propagate the error
(cache-invalidation is best-effort by trait contract).
Azure’s purge takes a contentPaths array, so a multi-URL save is
collapsed into a single request via the
PageCacheInvalidator::invalidate_urls override. Purges are
path-based (no per-host scope). Subtree purges use Azure’s /*
path glob.
Structs§
- Azure
CdnInvalidator - Azure CDN purge backend. Construct with
Self::new; chain.with_*configuration before installing on the admin router.