Getting caching working with Django

245 Views Asked by At

We are trying to implement caching in Django. We have tried memcache, file system caching and local memory caching. No mater what it just isn't working -- a timestamp we put on the template to test caching is always updating so we know it's not working.

Here are relevant portions of code.

CACHES = {
   'default': {
       'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
       'LOCATION': 'c:/tmp',
   }
}

CACHE_MIDDLEWARE_ALIAS = "default"
CACHE_MIDDLEWARE_SECONDS = 600

MIDDLEWARE_CLASSES = [
   "django.middleware.cache.UpdateCacheMiddleware",
    ... OTHER ONES ...
   "django.middleware.cache.FetchFromCacheMiddleware",
    ]

VIEWS.PY

from django.views.decorators.cache import cache_page

@cache_page(60 * 10)
def profiles(request, template_name="profiles/profiles.html", extra_context=None):
   ...
0

There are 0 best solutions below