1

I have a Django REST API, and I am using Redis as the caching backend.

Code

@method_decorator(cache_page(60*60))
    def dispatch(self, *args, **kwargs):
        return super().dispatch(*args, **kwargs)

It caches the data on a get call, but when I insert a new record, that new record is not showing up in the list (Which is coming from cache).

For eg: if there are 4 records in DB, they are being cached properly, but when I insert a new record, its not showing the get call.

Niyojan
  • 544
  • 1
  • 6
  • 23
  • 1
    Does this answer your question? [List of records not fetching updated records in Django REST framework..?](https://stackoverflow.com/questions/27242811/list-of-records-not-fetching-updated-records-in-django-rest-framework) – Wai Ha Lee Oct 11 '21 at 15:32
  • Nope. Actually the solution is to delete cache on update/delete/create using Django signals. I am actually surprised nobody talks about it anywhere. Or maybe it was so obvious that I should have implemented it in the first place. – Niyojan Oct 12 '21 at 14:02

0 Answers0