Django Book 翻译
菜单>:
TOC
返回
原文:
The cache middleware supports another setting, ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` . If youve defined this setting, and its set to ``True`` , then the cache middleware will only cache anonymous requests (i.e., those requests made by a non-logged-in user). This is a simple and effective way of disabling caching for any user-specific pages, such as Djangos admin interface. Note that if you use ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` , you should make sure youve activated ``AuthenticationMiddleware`` and that ``AuthenticationMiddleware`` appears before ``CacheMiddleware`` in your ``MIDDLEWARE_CLASSES`` .
翻译:
缓存中间件( cache middleware)支持另外一种设置选项, ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` 。如果你把它设置为“True”,那么缓存中间件就只会对匿名请求进行缓存, 匿名请求是指那些 没有登录的用户发起的请求。如果想取消用户相关页面(user-specific pages)的缓存,例如Djangos 的管理界面,这是一种既简单又有效的方法。另外,如果你要使用 ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` 选项,你必须先激活 ``AuthenticationMiddleware`` 才行,也就是在你的配置文件 ``MIDDLEWARE_CLASSES`` 的地方, ``AuthenticationMiddleware`` 必须出现在 ``CacheMiddleware`` 前面。
备注:
译者: