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.