Open Ask AI (⌘/Ctrl+I)

Personalize content with CDN caching

When using Magnolia’s personalization features (traits and variants) with CDN caching enabled, special configuration is required to ensure cached content respects user traits.

The problem

Magnolia DX Core allows you to create content variants that display different content based on user traits. However, when CDN caching is enabled:

  • Without caching: Users see personalized content correctly based on their traits.
  • With caching: All users see the same cached version (the first response the CDN cached), regardless of their traits.

This happens because CDNs treat all requests to the same URL as identical. The CDN caches the first response and serves it to everyone, ignoring trait differences.

The solution

Personalized content can be cached correctly by configuring the CDN to:

  1. Extract trait information from incoming requests
  2. Normalize trait values into a small set of categories
  3. Create separate cache entries for each trait category using the Vary header

Implementation approach

The configuration works in three stages of the CDN request lifecycle:

  1. Request received: Extract trait data (such as device type from User-Agent headers) and normalize it into categories
  2. Backend response received: Configure the Vary header to create separate cache entries for each trait category
  3. Response delivered: Clean up internal headers before sending the response to the client

Common personalization traits that work well with this approach include:

  • Device type (mobile, tablet, desktop)
  • Geographic region (continent or country-level)
  • User segments with limited categories

Getting personalization with caching configured

CDN configuration for personalized content caching is managed by Magnolia Support for DX Cloud projects.

To request this configuration:

  1. Contact DX Cloud support.
  2. Provide details about your personalization requirements:
    • Which traits you want to use (device type, location, etc.)
    • Expected trait values and categories
    • Which pages or content types require personalization
  3. Support will work with you to implement the appropriate CDN configuration.