First time here? Check out the FAQ!
0

How do I configure memcached for Django 1.3?

The default caching doesn't work. (There are numerous issues due to it.)

memcached is recommended. However, the settings.py is for Django <= 1.2 caching.

How do you configure memcached for Django 1.3?

Joseph's avatar
353
Joseph
asked 2012-07-24 23:25:23 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

[I will update these instructions if Evgeny tells me otherwise.]

Follow the memcache setup instructions described here: http://docs.webfaction.com/software/memcached.html and make sure python-memcached is installed.

Then, put the following in your settings.py:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': 'unix:/home/USERNAME/memcached.sock',
        'TIMEOUT': 18000,
        'KEY_PREFIX': 'askbot',
    }
}
CACHE_TIMEOUT = 18000
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

And disable the current CACHE_BACKEND. (The second CACHE_TIMEOUT is necessary because of a small bug.)

Also, disable the following middleware:

'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',

Otherwise you will get errors, like entire pages being cached when they shouldn't.

Joseph's avatar
353
Joseph
answered 2012-07-24 23:27:17 -0500, updated 2012-07-26 12:40:22 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments