﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15978	adding host to cache_key to enable subdomain caching	lpiatek@…	nobody	"If we try to run django on wildcard domain (all subdomains pointing one django app instance) there is problem when we turn on caching system. Django do not add any modificator to cache_key_suffix for subdomains. We get the same content on main page for different domain.

There is function in django.utils.cache._i18n_cache_key_suffix which django use to create prefix. To get it working I simply added one line which adds request.get_host() to this prefix. Details here:

http://stackoverflow.com/questions/3973852/django-caching-multi-domain-subdomain-wildcard-problem/4147366#4147366

I don't know is it the best solution You can choose. I'm waiting for others to comment.

Patch:
{{{
*** django/utils/cache.py       2011-05-06 21:40:42.000000000 +0200
--- ../django/utils/cache.py    2011-05-06 21:18:33.000000000 +0200
***************
*** 151,156 ****
--- 151,157 ----
          # LANGUAGE_CODE to request, then fall back to the active language
          # which in turn can also fall back to settings.LANGUAGE_CODE
          cache_key += '.%s' % getattr(request, 'LANGUAGE_CODE', get_language())
+     cache_key += '.%s' % (request.get_host())
      return cache_key

  def _generate_cache_key(request, method, headerlist, key_prefix):
}}}

PS: I'm now considering whether request.get_host() can return unicode? If yes there should be an u'' before string i guess? "	Bug	closed	Core (Cache system)	1.3	Normal	worksforme			Design decision needed	1	1	1	0	0	0
