Cache page based on cookie value and URL
You can do it without .htaccess rules.

Drupal core cache; modify in your settings.php file (apache only). From http://drupal.org/node/361832#comment-4204294

&lt;?php
// Check if cookie is set.
if (!empty($_COOKIE['my_cookie'])) {
  // Add cookie value to page cache id.
  $_SERVER['REQUEST_URI'] .= '#' . $_COOKIE['my_cookie'];

}
// Disable page cache if cookie not set so your magic code can set the cookie.
else {
  $conf['cache'] = CACHE_DISABLED;
}
?&gt;


Memcache
http://drupal.org/node/942914#comment-4477150