Thursday, September 19, 2013

Problem with authentication middleware, session and cache

Hi,

I' have some problems trying to cache most of my websites when  authentication mw is in place.

I only want to  cache anonymous users:

CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

anyway, I also want to show a different menu to authenticated users, so I also check for user.is_authenticated in a template tag for the menu.

It seems like like this check accesses the session and the mw then sets Vary=Cookie in the response, this prevents caching for users even if they are anonymous.

To make things more complicated I also need to use sessions in a few view (which are of course not cached).

Any suggestion about how to allow caching of my pages for anonymous users?


--
Alessandro Pasotti
w3:   www.itopen.it

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate