Django Caching - Remove caching for certain pages

前端 未结 1 726
礼貌的吻别
礼貌的吻别 2021-01-19 09:26

I would like to turn caching off for certain pages when that view is accessed. It\'s for a page that simply queries model objects.

it seems like when \'djan

相关标签:
1条回答
  • 2021-01-19 10:19

    https://docs.djangoproject.com/en/dev/topics/cache/#controlling-cache-using-other-headers

    If you want to use headers to disable caching altogether, django.views.decorators.cache.never_cache is a view decorator that adds headers to ensure the response won't be cached by browsers or other caches. Example:

    from django.views.decorators.cache import never_cache
    
    @never_cache
    def myview(request):
         # ...
    
    0 讨论(0)
提交回复
热议问题