Index: /home/chris/django/trunk/django/conf/global_settings.py
===================================================================
--- /home/chris/django/trunk/django/conf/global_settings.py	(revision 6964)
+++ /home/chris/django/trunk/django/conf/global_settings.py	(working copy)
@@ -157,6 +157,11 @@
 #    'django.core.context_processors.request',
 )
 
+# Number of seconds to cache templates retreived using the
+# django.template.loader get_template method (0 means no caching).
+# Templates are only cached if DEBUG is False.
+CACHE_TEMPLATES = 600
+
 # Output to use in template system for invalid (e.g. misspelled) variables.
 TEMPLATE_STRING_IF_INVALID = ''
 
Index: /home/chris/django/trunk/django/template/loader.py
===================================================================
--- /home/chris/django/trunk/django/template/loader.py	(revision 6964)
+++ /home/chris/django/trunk/django/template/loader.py	(working copy)
@@ -21,6 +21,7 @@
 # installed, because pkg_resources is necessary to read eggs.
 
 from django.core.exceptions import ImproperlyConfigured
+from django.core.cache import cache
 from django.template import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins
 from django.conf import settings
 
@@ -75,9 +76,34 @@
     """
     Returns a compiled Template object for the given template name,
     handling template inheritance recursively.
+    
+    If settings.DEBUG is False, settings.CACHE_TEMPLATES is non-zero and the
+    template source is found, then the compiled template is cached.
     """
+    if settings.DEBUG:
+        cache_template_duration = 0
+    else:
+        cache_template_duration = settings.CACHE_TEMPLATES
+    if cache_template_duration:
+        # Try to retreive the template from cache before looking through
+        # template_source_loaders for it.
+        cache_name = 'django.template.loader.%s' % template_name
+        template = cache.get(cache_name)
+        if template:
+            return template
+        elif template == 0:
+            # This template couldn't be pickled, don't try again.
+            cache_template_duration = 0
     source, origin = find_template_source(template_name)
     template = get_template_from_string(source, origin, template_name)
+    if cache_template_duration:
+        try:
+            cache.set(cache_name, template, cache_template_duration)
+        except TypeError:
+            # Template couldn't be pickled, most likely because of an decorated
+            # filter (Python 2.3 can't pickle any filter decorated with
+            # stringfilter).
+            cache.set(cache_name, 0, cache_template_duration)
     return template
 
 def get_template_from_string(source, origin=None, name=None):
Index: /home/chris/django/trunk/docs/settings.txt
===================================================================
--- /home/chris/django/trunk/docs/settings.txt	(revision 6964)
+++ /home/chris/django/trunk/docs/settings.txt	(working copy)
@@ -269,6 +269,18 @@
 The default number of seconds to cache a page when the caching middleware or
 ``cache_page()`` decorator is used.
 
+CACHE_TEMPLATES
+---------------
+
+Default: ``600``
+
+The number of seconds to cache a template loaded and compiled from the file
+system.
+
+Note that Django will only cache templates if ``DEBUG`` is ``False``.
+
+See also ``DEBUG``.
+
 DATABASE_ENGINE
 ---------------
 
