Can't get Django view to never cache when accessing via browser
I have a Django app hosted on a Linux server served by NGINX.
A view called DashboardView displays data from a Postgresql database. This database gets routinely updated by processes independent of the Django app.
In order for the latest data to always be displayed I have set the view to never cache. However this doesn't seem to be applied when viewing in the browser. The only way I can force through the view to show the updated data is via a GUNICORN restart on the server.
When I look at the the Network details in Google Chrome devtools everything looks set correctly. See below the cache control details shown.
max-age=0, no-cache, no-store, must-revalidate, private
Please see Django code below setting never cache on the DashboardView.
from django.utils.decorators import method_decorator
from django.views.decorators.cache import never_cache
class NeverCacheMixin(object):
@method_decorator(never_cache)
def dispatch(self, *args, **kwargs):
return super(NeverCacheMixin, self).dispatch(*args, **kwargs)
class DashboardView(NeverCacheMixin, TemplateView):
...................code for view.............
I am at a loss as what to look at next. The session IDs don't seem to change after a GUNICORN restart so I don't think its related to this.
Where could this be failing?