Django Cache Middleware on App Engine

6 views
Skip to first unread message

GAEfan

unread,
Nov 12, 2009, 12:52:07 AM11/12/09
to Google App Engine
I am trying to implement Django's Cache Middleware, and can't seem to
get it to work. Here is what I have:

settings.py:
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware', # this must be
first
'ragendja.middleware.ErrorMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', # this
must be before CacheMiddleware
#'django.middleware.cache.CacheMiddleware', #
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware', # this must be
last
)

CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

CACHE_BACKEND = 'memcached://?timeout=120'

By using apiproxy_stub_map.apiproxy.GetPostCallHooks(), I can see that
the memcache is set every time the url is hit. It never 'gets' the
memcache. In other words, the cache is set every time, but never
called. I never get a cached view, even though it is set into
memcache.

I have tried this method of site-wide caching, and also used the
decorator:

from django.views.decorators.cache import cache_control
@cache_control(max_age=300)
def myview...

Pulling my hair out here... Is there something I'm missing?

Thank you.

GAEfan

unread,
Nov 12, 2009, 1:31:52 AM11/12/09
to Google App Engine
Also, I am using app-engine-patch, and importing Django-1.1.zip

Thanks.

GAEfan

unread,
Nov 12, 2009, 10:31:31 AM11/12/09
to Google App Engine
I Should add that the memcache is properly set (memcache.Set), and
shows "set_status: 1 ". So the problem is that the next view of the
page does not ever get the cached version. No visitor ever gets a
"memcache.Get"

What (in App Engine and/or Django) tells a new Request to get a cached
Response?
Reply all
Reply to author
Forward
0 new messages