Speed Optimizer by SiteGround (and SiteGround’s server-level caching) can serve a page geolocated for one visitor to everyone. To keep CBR PRO’s country detection working, bypass the cache for visitors who have selected a country. Background: How CBR PRO Detects the Customer’s Country.
Bypass the country Cookie
Add the following PHP snippet to your child theme’s functions.php file, or add it with a code-snippets plugin. (Don’t edit the parent theme — your change would be lost on the next theme update.) It tells Speed Optimizer to bypass the cache whenever the visitor has the country cookie:
add_filter( 'sgo_bypass_cookies', 'cbr_add_sgo_bypass_cookies' );
function cbr_add_sgo_bypass_cookies( $bypass_cookies ) {
// Bypass the cache for visitors with a selected country.
$bypass_cookies[] = 'country';
return $bypass_cookies;
}
Purge the Cache
After adding the snippet, purge the cache (Speed Optimizer → Caching → Purge Cache, or the Purge SG Cache button in the admin bar) so previously cached country-specific pages are removed.
Next Steps
- Compatibility — general caching guidance and other cache plugins.
- How to Use with WP Rocket — the equivalent setup for WP Rocket.