Django每站点缓存未更新 [英] Django per-site cache not updating

查看:44
本文介绍了Django每站点缓存未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用设置了每个站点的缓存https://docs.djangoproject.com/zh-CN/1.5/topics/cache/#the-per-site-cache 文档.但是我看到页面缓存在数据更改后不会更新.我是否必须以某种方式手动使其无效,或者某些配置不正确?如文档中所述,UpdateCacheMiddleware在我的配置中排在第一位,而FetchFromCacheMiddleware在我的配置中排在最后.

I have set up per-site cache using https://docs.djangoproject.com/en/1.5/topics/cache/#the-per-site-cache documentation. But I see that the page cache doesn't update after the data change. Do I have to invalidate it manually somehow, or something is just improperly configured? UpdateCacheMiddleware goes first in my config and FetchFromCacheMiddleware goes last, as told in the doc.

推荐答案

如果要缓存整个站点,则直到缓存过期,缓存才会反映更新的更改.如果您打算对动态页面进行定期更改,那么您将需要使用较低级别的缓存(按视图,模板片段等)并实现缓存无效化.这可能会变得非常复杂,因此,如果您可以在短时间内显示过时的数据,则可能会避免麻烦.

If you are caching the entire site, the cache will not reflect the updated changes until the cache has expired. If you are looking at making regular changes to dynamic pages, then you will want to go with a lower-level cache (per-view, template fragment, etc.) and implement cache invalidation. This can get pretty complicated, so if you can get away with displaying stale data for a short period of time, you may find that saves you from getting a few headaches.

这篇关于Django每站点缓存未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆