Tuesday, 15 June 2010

django - partly caching a view method -



django - partly caching a view method -

i using memcached (with python-memcached binding) 1 of django projects. scenario on homepage have:

a top bar : (this contains links login / user name link profile) a search form few blocks of results

currently, using cache_page() decorator cache whole page follows:

@cache_page(3600) def home(request): # view code goes here

and above working expected. homepage publicly accessible page facing problem 1 scenario where:

an anonymous user request home page(the page get's cached if not already). now user logs in , redirected homepage. the cached homepage loads (topbar still shows login link instead of logged in user's name , profile link page cached before user logged in.) question:

is there way either on template level or on view level, lets specify block do not want cache while using cache_page() decorator ?

please note: aware can utilize {% cache %} template tag or cache.set each block in above scenario. looking solution can utilize cache_page() decorator , still able specify block not want cached in particular view or template

use cache_middleware_anonymous_only

yet sounds middleware option, affects @cache_page well

django caching memcached

No comments:

Post a Comment