开发者

Cache for everybody except staff members [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

I have a django site where I want to stick an "admin bar" along the top of every non-admin page for staff members. It would contain useful things like page editing tools, etc.

The problem comes from me using the @cache_page decorator on lots of pages. If a normal user hits a page, the cached version comes up without the admin bar (even for admin users) and if an admin hits the page first, normal users see the admin bar.

I could tediously step through the templates, adding regional cache blocks but the开发者_开发百科re are a lot of templates, and life is altogether too short.

Ideally, there would be a way of telling the caching to ignore cache get/set requests from admin users... But I don't know how to best implement that.

How would you tackle this problem?


I actually didn't tell you the entire truth.. The only logged in people are staff members. Everybody else is anonymous.

Digging through the cache middleware source (what @cache_page uses) I found the CACHE_MIDDLEWARE_ANONYMOUS_ONLY setting!

I believe this should fix things for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜