Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of Cache Varients on VIP Go
<?php
/**
* Example of Cache Varients on VIP Go
*
* @see https://github.com/Automattic/vip-go-mu-plugins/blob/master/cache/examples/segmentation-maintenance-mode-bypass/vip-config.php
*/
function x_cache_seg() {
// Set the response header to let CDN know of possible varient.
header( 'Vary: X-VIP-Go-Segmentation' );
// Check the inbound request header for vip-go-seg Cookie.
$segment = $_COOKIE['vip-go-seg'] ?? '';
if ( "humans" === $segment ) {
echo 'hello humans! 👋';
} elseif ( "aliens" === $segment ) {
echo 'hello aliens! 🖖';
} else {
echo 'hello world!';
}
die;
}
x_cache_seg();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.