Skip to content

Instantly share code, notes, and snippets.

@davidsword
Created November 25, 2019 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/f0e3ffc5026318c561dab25692a9e35b to your computer and use it in GitHub Desktop.
Save davidsword/f0e3ffc5026318c561dab25692a9e35b to your computer and use it in GitHub Desktop.
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