Manage 2 separate page cache for the same URI We have a multilingual website build with Drupal 7.

We have a IP detection for detect Chinese users. Chinese laws do not allow the use of certain JS librairies. In our case, for one page, we use Google Map for all the users in the world, and we replace the library with Baidu Map for Chinese IP.

The problem is that if the first user is Chinese, then Drupal will cache the page with BaiduMap. Anonymous users from all the world will then have the page with Baidu Map even if there aren't Chinese (since it is the same URI).

We can detect if the IP is Chinese or not. So, how can we handle 2 separate page cache according to the user IP and then call the right cached page ?
This assumes that the theme is changing.

Settings.php file:

// Check if cookie is set.
if (!empty($_COOKIE['custom_theme'])) {
  // Add theme name to page cache id.
  $_SERVER['REQUEST_URI'] .= '#' . $_COOKIE['custom_theme'];
  // Set Theme.
  $conf['theme_default'] = $_COOKIE['custom_theme'];
}
// Disable page cache if cookie not set so hook_init code can set the cookie.
else {
  $conf['cache'] = CACHE_DISABLED;
}


hook_init():

  // If no cookie is set set a cookie with the value of theme_default.
  if (empty($_COOKIE['custom_theme'])) {
    $temp = empty($custom_theme) ? variable_get('theme_default') : $custom_theme;
    setcookie('custom_theme', $temp, time() + 60*60*24*30, ini_get('session.cookie_path'), ini_get('session.cookie_domain'));
  }