Django 包含一个灵活的缓存框架,支持多个缓存级别(整个页面、视图结果、模板片段或任意数据)和多个后端(内存、Redis、Memcached、数据库)。缓存避免了重复的昂贵工作——这是性能优化中影响最大的方法之一。
配置缓存后端
# settings.py — Redis is the common production choice (shared across servers)
CACHES = {
"default": {
: ,
: ,
}
}
