Created
November 25, 2019 18:46
-
-
Save davidsword/f0e3ffc5026318c561dab25692a9e35b to your computer and use it in GitHub Desktop.
Example of Cache Varients on VIP Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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