Skip to content

CDN and Caching Architecture

advanced
📜Advancedcms

Your site’s perceived speed depends more on caching than on raw server performance. A well-configured CDN serves most requests from edge locations close to the user, avoiding round trips to your origin server entirely. A misconfigured cache delivers stale content, leaks personalized data, or forces every request back to origin — negating the entire benefit. Understanding the caching layer is critical for both performance and correctness.


Optimizely Cloud includes a CDN (Content Delivery Network) powered by a global edge network. The CDN sits between your users and your application, caching responses at points of presence (PoPs) around the world.

User → Nearest CDN Edge → (Cache Hit?) → Return Cached Response
↓ (Cache Miss)
Origin Server → Generate Response → Cache at Edge → Return

When a user requests a page, the CDN checks its local cache first. If the content is cached and still valid (not expired), the response is served directly from the edge with no origin request. If the cache is empty or expired, the CDN forwards the request to your application, caches the response, and serves it.

The CDN operates PoPs across major metropolitan areas worldwide. Each PoP maintains its own cache, so content is cached independently at each location. A page cached in Amsterdam is not automatically available in Tokyo — the Tokyo PoP caches it on first request from that region.


The CDN respects standard HTTP cache headers sent by your application:

HeaderEffect
Cache-Control: public, max-age=3600CDN caches for 1 hour
Cache-Control: privateCDN does not cache; response is per-user
Cache-Control: no-cacheCDN revalidates with origin on every request
Cache-Control: no-storeCDN does not cache or store the response
Vary: CookieCDN caches separate versions per cookie value

Optimizely CMS sets cache headers based on content type and publishing state:

  • Published pages — Cached with configurable duration (default: 10 minutes for server-side, longer for CDN)
  • Edit mode — Never cached; Cache-Control: no-store is set automatically
  • Personalized content — Varies by visitor group; the Vary header prevents cross-user leakage
  • Static assets — Long cache duration with content-based hash in the filename for cache busting

The CDN cache key is composed of:

  1. URL path — The request path including query string
  2. Host header — The domain name
  3. Vary headers — Any headers listed in the Vary response header

Two requests with identical URLs but different Vary header values produce separate cache entries. This is how personalized content avoids serving one visitor’s content to another.


When content changes, stale cache entries must be cleared. Optimizely Cloud supports several purge approaches.

When an editor publishes content in the CMS, the platform automatically purges the CDN cache for the affected URLs. This includes:

  • The published page’s URL
  • Any listing pages that reference the published content
  • API endpoints that serve the content

Through the management portal or CLI, you can purge:

  • Single URL — Clear one specific cached resource
  • Path prefix — Clear everything under a URL path (e.g., /en/blog/*)
  • Full purge — Clear the entire CDN cache for an environment

For automated workflows, the purge API accepts URL patterns and executes purges programmatically. This is useful in CI/CD pipelines where a deployment should clear specific cached assets.

Not all content needs active purging. Setting appropriate max-age values lets content expire naturally:

Content typeRecommended max-age
HTML pages5-15 minutes
CSS/JS bundles1 year (with hash-based filenames)
Images and media1-7 days
API responses1-5 minutes
Fonts1 year

Personalized content requires special handling at the CDN layer. If a page shows different content to different visitors, a naive cache would serve visitor A’s personalized content to visitor B.

The preferred pattern is to cache the page shell at the CDN and load personalized fragments separately. The main page is fully cacheable, and personalized components fetch their content via client-side API calls that bypass the CDN cache.

Alternatively, the Vary header can create separate cache entries per visitor segment. However, this reduces cache hit rates because each segment produces a distinct cache entry. Use this approach only when the number of segments is small and well-defined.

For highly dynamic pages (search results, user dashboards, checkout flows), bypass CDN caching entirely with Cache-Control: no-store. These pages are served directly from origin on every request.


The cache hit ratio measures what percentage of requests are served from cache versus origin. Target above 85% for content sites. Monitor this metric in the management portal under CDN analytics.

  • Below 60% — Review cache headers; likely too many no-cache or private directives
  • 60-85% — Acceptable, but look for optimization opportunities
  • Above 85% — Healthy caching behavior

CDN-served responses typically complete in 5-50ms regardless of user location. Origin-served responses depend on application processing time plus network latency to the origin region.