I use Django 5/Gunicorn/Nginx stack and my relevant cache related settings:
...
MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware",
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
"django.middleware.cache.UpdateCacheMiddleware",
'django.middleware.common.CommonMiddleware',
"django.middleware.cache.FetchFromCacheMiddleware",
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "127.0.0.1:11211",
}
}
...
I use @cache_page(60 * 60 * 24 * 30)
decorator to cache some of my views, which are expected to change very rarely. But if it changes, it must go live immediately. I tried to clear the cache by the following way resulting no success:
- Restarting Gunicorn
- Restart Nginx
- Reboot the development server
- Clear the cache from the django shell by
cache.clear()
Any idea to solve this is a great help.
Thanks in advance.