> For users who aren't logged in, the pages would be the same. However, if a
> user is logged in, then there are links to the users' profile, as well as a
> logout link; thus making the page different for every user, and different
> for logged-in vs. non-logged-in users. Is there any way to effectively
> cache these pages, or only cache the non-logged in page for non-logged in
> viewers?
>
cache.action does two things -- it sends appropriate response headers to
the browser to enable client-side caching, and it (optionally) does
server-side caching via the web2py cache mechanism. You might want to avoid
doing per-user server-side caching, as that will start to fill up server
memory, and you'd have to make sure you manually clear cached values
periodically. Maybe consider something like:
@cache.client(cache_model=cache.ram if not auth.is_logged_in() else None,
public=not auth.is_logged_in(), ...)
That will do server-side caching of the non-logged-in page only, and it
will set public client-side caching to False for logged in users.
> Secondly, cache.action can't be used to cache views with database selects.
> However, if the database select was converted to a list/dict, with
> as_list() or as_dict(), would caching the page with cache.action be
> possible (this would make it pickleable as a regular dictionary)?
>
Not sure what you mean -- can you show some code? cache.action caches only
the output of the decorated function (and only if cache_model is specified
-- otherwise, all it does is send headers to the browser to enable
client-side caching).
Anthony
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.