From 10bcb50ffffbe93a6033595ae79b18124fb4e1c0 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Wed, 26 Oct 2016 13:24:36 +0200 Subject: [PATCH] Recommend Django's cached template loader As noted in PR #3077: "With the cached template loader enabled, there's a significant performance improvement" --- docs/advanced_topics/performance.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/advanced_topics/performance.rst b/docs/advanced_topics/performance.rst index d44eb9b732..f9622968a5 100644 --- a/docs/advanced_topics/performance.rst +++ b/docs/advanced_topics/performance.rst @@ -55,6 +55,27 @@ Database Wagtail is tested on SQLite, and should work on other Django-supported database backends, but we recommend PostgreSQL for production use. +Templates +--------- + +The overhead from reading and compiling templates can add up. In some cases a significant performance improvement can be gained by using `Django's cached template loader `_:: + + TEMPLATES = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'OPTIONS': { + 'loaders': [ + ('django.template.loaders.cached.Loader', [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + ]), + ], + }, + }] + +There is a caveat associated with this loader though. Changes to a template file will not be picked up once it is cached. This means that this loader should *not* be enabled during development. + + Public users ~~~~~~~~~~~~