Django缓存 - 清除缓存 [英] Django caching - purge cache
问题描述
例如,假设我有最简单的网站,一个博客。直到我提交一个新的帖子,首页不会改变,所以我可以使用HTML缓存几天,但我想要一个方法来说刷新缓存现在每当我提交一个新的帖子,所以在新的提交之后,我的网站的第一次调用不使用缓存的HTML,但生成一个新的页面将被使用,直到我的下一篇博文。
如何做?感谢
编辑:
cache.clear )
运行良好,按预期,但我想要一个更特定的选项,我可以指定什么视图到期,而不是整个缓存。谢谢。
看起来像这个将工作。在这个线程中还有一些更深入的解释。
I want a simple behaviour from the caching mechanism, but I can't find a way to obtain it. I'd be fine with per-site or per-view caching, but I want some sort of control on when to invalidate cache.
For example, imagine that I have the simplest kind of site, a blog. Until I submit a new post, the frontpage doesn't change, so I'm ok with the HTML to be cached for days, but I'd like a way to say "refresh the cache now" whenever I submit a new post, so that the first call to my site after the new submission doesn't use the cached HTML but produces a new page that is going to be used till my next blog post.
How to do this? Thanks
EDIT:
cache.clear()
works well and as expected, but I'd like a more "specific" option where I can specify what view to expire, not the whole cache. thanks.
Looks like this will work. There is some more in depth explanation in that thread as well.
这篇关于Django缓存 - 清除缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!