Book Image

Django 1.0 Template Development

Book Image

Django 1.0 Template Development

Overview of this book

Table of Contents (17 chapters)
Django 1.0 Template Development
Credits
About the Author
About the Reviewers
Preface
Index

Caching your whole site


If you want to cache your entire site without having to configure the cache for each individual view, Django provides middleware that can do this for you.

Edit the MIDDLEWARE_CLASSES tuple in your mycompany/settings.py file to look like this: (add the highlighted lines)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',    
)

The order of the classes in the tuple is important, so make sure you add them exactly as listed. If you're not using all of these pieces of middleware and your tuple looks different, just make sure you put the highlighted lines around the CommonMiddleware element.

Add the following lines to your mycompany/settings.py file:

CACHE_MIDDLEWARE_SECONDS =...