I am working on a site that is multi-lingual as well as multi-country. This means that pages will show content differently depending on a country cookie that is set when the user first visits the site. I used taxonomy tid's for the cookie's value, so there was no issue with case sensitivity, etc.
The problem is that Drupal's cache_page table indexes content by URL only, so users with different countries but the same URL all get the same content. I was able to get the effect I wanted just by modifying the mod_rewrite implementation:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !(cid)
RewriteCond %{HTTP_COOKIE} (?:^|;\s*)country=([^;]*)
RewriteRule ^(.*)$ $1?cid=%1&%{QUERY_STRING} [L,R=302]
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} (?:^|;\s*)country=([^;]*)
RewriteRule ^$ /?cid=%1 [L,R=302]
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I did have to disable the ExpiresDefault directive, as it was causing the browser to remember old content when the user switches countries.
The resulting cid's in the cache_page table look like this:
http://example.com/pagename?cid=98
http://example.com/pagename?cid=256
This post isn't so much of a "help me I'm stuck" but a "I had this problem, and here's how I solved it. Can you think of a better way to do this?"