0

I read the documentation as well but could not get clearing on this. Also, do we need to install anything extra for this to work? I have added below code in settings.py file :

    CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/var/tmp/django_cache',
        'TIMEOUT': 518400,  # 6 days - 6*24*60*60
        'OPTIONS': {
            'MAX_ENTRIES': 1000
        }
    }
}

MIDDLEWARE_CLASSES += [
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
]
sid8491
  • 6,622
  • 6
  • 38
  • 64
  • 3
    The cached pages are on the server in the directory specified -- `/var/tmp/django_cache`. As a rule, web pages in browsers (more specifically the JavaScript(s)) do *not* have permission to write to the local filesystem. This is A Good Thing. Otherwise you would have a security hole big enough you could drive a 747 through it. – Peter Rowell Jul 16 '16 at 18:14
  • @PeterRowell : but why I cannot see any files building into the directory and if web browsers don't have permission then will caching work? – sid8491 Jul 17 '16 at 12:50
  • Without further information, my guesses are: the directory does not exist, you lack necessary permissions to create / write files there, and/or you are not using per-view caching or the `{% cache %}` tag in your templates. Did you [Read *all* of The Friendly Manual](https://docs.djangoproject.com/en/1.9/topics/cache/#template-fragment-caching)? – Peter Rowell Jul 17 '16 at 15:47
  • @PeterRowell, sir i have created /var/tmp/django_cache in the root of the project, and also gave the 777 permissions. not using any tag inmy template, using per-site caching. – sid8491 Jul 17 '16 at 18:31

0 Answers0