On Thu, Dec 17, 2009 at 03:54:02PM -0200, Victor Loureiro Lima wrote: > Okay, let me further explain my problem... > > My website depends heavilly on the caching system, I'm using cache_page to > cache my view ( using memcached backend ), > however I have the "Hello, <logged in user>" on top of every page when the > user is logged, thus I cant just cache everything.
Well, there is (now) a mechanism in place for caching template fragments. So I suppose you could cache everything but the hello... I haven't tried to use caching in such fine-grained fashion though: http://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching > as a side note, I had to apply a patch to > django, in order for it to ignore certain cookie name regexp's Dirty, but if you're already mangling the django cache code to vary on a subset of cookies rather than the standardised behaviour of varying on all cookies (since it's really varying on the "Cookie" HTTP header), you could probably further mangle it to vary only on a custom cookie other than the django session cookie. I don't think this is a good approach, just saying. > That solved my problem, using @vary_on_cookie on my views, now I solved my > caching issues, however I noticed that whenever a user logs out, I recieve a > new sessionid, thus if the user log's in I will create a cache for him, > based on its session id. But when it logs off, instead of joining the other > clients that dont have the sessionid, it will become another "cached > instance", and I have to avoid that situation. How about clients that have a sessionid before login? you may be assuming clients don't have a session cookie before they login? That may wind up true in your case I guess, but n.b. don't think that login creates sessions in general - it may "bless" an existing anonymous session with data in it into ownership by the logger-in (except when the existing session is already owned by someone logged in, then it is replaced for security). http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/__init__.py#L65 This is a feature - consider user starting filling out a form anonymously, data being stashed in the session, then user logs in to authorise doing something (posting comment, say). -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.