I have spent several hours researching this, and I'm stumped, so
perhaps I could tap into some collective wisdom:

I have a website whose page template includes a "Sign-In or Register"
link at the top.   This is shown on pretty much every page.  If the
user is already signed in, this is replaced with "Hello _username_ |
My Account".  This is done by passing request.user to the template and
checking is_authenticated().

The problem is, that as soon as I touch request.user, the Vary: Cookie
header is tagged on, and that destroys caching.  Every anonymous user
gets their own version of the page cached, which is almost pointless.

I'm trying to figure out a way that I can fully utilize the cache for
anonymous users (i.e. one instance of the rendered page in the cache)
and I'm OK for caching with Vary: Cookie for logged in users.

So, is there a way to figure out if the user is logged in or not,
without tripping the Vary: Cookie header, or is there a better way of
doing this altogether?

BTW, it seems that it is significantly faster (15x CPU time) to cache
a whole view, that to cache a fragment, so I'd like to avoid that if
possible.

Thanks

Thanos

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to