Blog

CDN caching and CORS: Vary, surrogate keys, and pitfalls

If responses differ by Origin, caches must vary correctly or users see cross-talk.

1 min read
cdncachecors

Vary header essentials

When Access-Control-Allow-Origin echoes a specific origin, caches should include Vary: Origin.

Misconfigured caches can serve Site A’s allowed origin to Site B’s users—debug with curl from multiple Origins.

APIs behind CDNs

Purge by surrogate key when you rotate CORS policy globally.

Short TTLs on error responses prevent sticky bad states after misconfiguration.

Back to blog