I need to decorate a controller function with @cache.action in order to have two different versions of the rendered view: one for logged-in users and another one for not logged-in users.
Notice that I don't need one different caché for each user (that could be achieved using session argument). Instead, what I need is two versions of the rendered view: one for all the users that aren't logged-in, and one for all the users that are logged-in. The only difference between those two versions of the rendered view is that one of them includes a top navbar, which is is the same for all logged-in users, but it shouldn't be present in the cache version for not logged-in users. Because I need the same behaviour in several controller functions, the way I do it is defining the @cache.action parameters at the models level, like this: CACHE = Storage() CACHE.prefix = '' CACHE.time_expire = 300 CACHE.public = True CACHE.session = False CACHE.vars = False if auth.is_logged_in(): CACHE.prefix += 'logged-in-' CACHE.public = False # CACHE.model = None The I use that configuration in controller functions: @cache.action(time_expire=CACHE.time_expire, cache_model=CACHE.model, session=CACHE.session, vars=CACHE.vars, public=CACHE.public, prefix=CACHE. prefix) def index(): return response.render(...) @cache.action(time_expire=CACHE.time_expire, cache_model=CACHE.model, session=CACHE.session, vars=CACHE.vars, public=CACHE.public, prefix=CACHE. prefix) def forum(): return response.render(...) However, I'm having trouble to make it work as I want. It's not working entirely wrong, but the problem is this: 1) the user hits the index, without being logged-in; 2) the user logs in 3) the user goes back to index, but still sees the cached page (I think it's the browser that is using local cache). If the user reloads the page (hitting F5 or Ctrl+R), then the new view is shown. What am I missing? As you can see in the code, I've tried: - setting public=False regardless of the logged in state; - setting cache.model=None when the user is logged-in; - using a different prefix for logged in users; But the problem remains: after logging in, the user need to hit F5 in order to see the other view. As always, I will appreciate any help on this. Regards, Lisandro -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.