Django缓存框架。 TIMEOUT和CACHE_MIDDLEWARE_SECONDS有什么区别? [英] Django cache framework. What is the difference between TIMEOUT and CACHE_MIDDLEWARE_SECONDS?
问题描述
确实,相应的文档没有充分解释差异。
第一个选项 CACHES
: TIMEOUT
在 Django缓存框架,缓存参数。这是在$ code> cache.set()等函数中使用的默认过期时间,如果没有提供。稍后在低级缓存API使用情况中记录。
后者 CACHE_MIDDLEWARE_SECONDS
在 Django缓存框架,每个站点缓存。因此,假设它是所有页面的默认过期时间,可能是安全的,就好像 @cache_page(settings.CACHE_MIDDLEWARE_SECONDS) =https://docs.djangoproject.com/en/1.8/topics/cache/#the-per-view-cache =nofollow>每个视图基础。
I have been setting up caching in Django using a database cache. There are two settings TIMEOUT and CACHE_MIDDLEWARE_SECONDS that control how long a page is cached for. What is the difference between these two settings?
Indeed the respective documentation does not adequately explain the differences.
The first option, CACHES
: TIMEOUT
is introduced in Django cache framework, Cache arguments. It is the default expiration time that is used in functions such as cache.set()
, if none else is provided. This is later documented in the low-level cache API usage.
The latter, CACHE_MIDDLEWARE_SECONDS
is introduced in Django cache framework, The per-site cache. Therefore it might be safe to assume that it is the default expiration time for all pages, as if the @cache_page(settings.CACHE_MIDDLEWARE_SECONDS)
would have been used on a per-view basis.
这篇关于Django缓存框架。 TIMEOUT和CACHE_MIDDLEWARE_SECONDS有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!