The VIP Cache Personalization API
When serving dynamic content within a Content Management System (CMS), there are two ends of the spectrum of caching behaviors:
- Generate each page every time a user request comes. This ensures the user always has the most up-to-date copy but comes with a performance penalty as the code and database calls run each time.
- Generate a page once and then cache the content for future requests. This option offers improved performance but requests potentially display outdated content until it is regenerated.
Caching is essential for achieving the high levels of scaling and performance that many applications expect. By default, the VIP CDN is configured to maximize cache hit rates. The VIP Cache Personalization API provides a way to customize the default caching behavior of the VIP CDN while still leveraging the power and scale that it provides.
Some common uses for the VIP Cache Personalization API include:
- Tailoring content to a user’s location (geotargeting).
- Displaying different website features to a select group (e.g. Beta site).
- A/B testing.
- Gating content until users opt-in (e.g. Accepting Terms and Conditions).
- Content paywalls.
- Membership sites using custom authentication systems.
- Third-party integrations that require uncached content/resources.
Cache Personalization API implementations
More details about the Cache Personalization API and code examples can be reviewed in the GitHub repository for the Vary_Cache
class.
Audience segmentation
Audience segmentation is useful for serving different cached content to different constituencies in an audience. The VIP Cache Personalization API allows a new cache group to be created and users to be assigned to specific segments within that group.
For example, when introducing Beta features for a site, a new group called “beta” can be created to allow users to opt-in to those features. Two user segments can be created in that group: users who have opted into the beta and those who have not.
An unlimited number of groups can be created, and users can belong to multiple groups and segments. The higher the number of groups that exist, the higher the variance in caching responses. This can decrease cache efficacy and performance and should be used cautiously.
At a technical level, when a user is assigned to an audience segment, the API sets a cookie defining the user’s group or groups.
Encrypted audience segmentation
Encrypted audience segmentation is similar to audience segmentation, but ensures that it is not possible for even a very savvy technical user to change the segments they have been assigned to. Typical use cases for this are paywalls, authenticated content, and other situations where it is desired for cached content to not be visible to a user based on encrypted credentials.
At a technical level, the cookie defining the group or groups the user is part of contains an encrypted string that cannot be read or altered by the user without scrambling the content.
The option to encrypt audience segmentation is not enabled by default. Customers can create a VIP Support request and indicate which environment(s) should enable this feature.
Cache bypass
Caution
Disabling caching can have detrimental effects on site performance.
Cache bypass turns off all caching for a given visitor. This is useful for third-party services that consume data or content from an application and require uncached data. It is also applicable when working with an external authentication system.
Last updated: December 22, 2023