The VIP Cache Personalization API
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.
The VIP Cache Personalization API utilizes the Vary_Cache class to customize some of the behaviors of the page cache while still leveraging the power and scale provided by VIP’s CDN. 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.
Some common uses for the VIP Cache Personalization API:
- Tailoring content to a user’s location with IP geolocation
- 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
- Custom authentication systems for membership sites
Note
Review more details about the VIP Cache Personalization API and related code examples in the VIP MU plugins GitHub repository for the Vary_Cache class.
Limitation
Cache personalization cannot be applied to requests that bypass the page cache (e.g. requests made to WordPress environments by logged-in users).
The vip-go-seg cache segmentation cookie
The VIP Platform vip-go-seg cache segmentation cookie passes its assigned value to an application in the vary: x-vip-go-segmentation HTTP response header. If the passed value matches a segment string that is defined in application code, content from a specified cache bucket will be served in response.
Because it does not rely on the IP address of an end user, the vip-go-seg cookie can be successfully used to vary cache responses by a site that is behind a reverse proxy.
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.
Encrypted audience segmentation is not enabled by default. Enabling it requires both a platform configuration change by VIP and a code change in the application, and these must be completed in the following order:
- Create a VIP Support request and indicate which environment(s) should enable encrypted audience segmentation. VIP Support will confirm when the feature has been enabled for each requested environment.
- After VIP Support has confirmed, deploy code to those environments that calls
Vary_Cache::enable_encryption(). The method must be called before theinithook runs, for example in a file in theclient-mu-plugins/directory.
<?php
// Load the VIP Vary_Cache class.
require_once WPVIP_MU_PLUGIN_DIR . '/cache/class-vary-cache.php';
use Automattic\VIP\Cache\Vary_Cache;
Vary_Cache::enable_encryption();Caution
If Vary_Cache::enable_encryption() runs on an environment where VIP has not enabled encrypted audience segmentation, it triggers a fatal PHP error and requests to that environment fail with a 500 error.
Note
The cache_segment field in shipped HTTP request edge logs always reflects the raw vip-go-seg value and is not affected by encryption — it shows the same value whether or not Encrypted audience segmentation is enabled.
Last updated: October 16, 2026