I'm googling a lot to find out what Django Rest Framework can do with Cache. Since now, all I got was this page
http://django-rest-framework.org/api-guide/throttling.html
telling me nothing about their policy.
My needs with the API are simple: keep all their features, and apply cache when nothing has changed. When something changes in DB, have a mechanism to invalidate proper cache pages.
For example:
If I have list and detail views of models AB, through an API with authentication and throttling, I want to:
So, all I need is to know how django rest framework create keys, and which is the point they cache it to have the control of cache policy.
Any clues?
structure, setting CACHES = None or CACHES['default']['BACKEND'] = None causes Django to choke, and setting CACHES = {} still seems to enable basic caching.
Using cache with apiview and viewsets Django provides a method_decorator to use decorators with class based views. This can be used with other cache decorators such as cache_page , vary_on_cookie and vary_on_headers . NOTE: The cache_page decorator only caches the GET and HEAD responses with status 200.
If you would like to store cached data in the database, Django has a backend for this purpose. To save cached data in the database, you just need to create a table in the database by going to the settings.py file, setting BACKEND to django. core. cache.
Unless we explicitly specify another caching method in our settings file, Django defaults to local memory caching. As its name implies, this method stores cached data in RAM on the machine where Django is running. Local memory caching is fast, responsive, and thread-safe.
Even if the question is not new, maybe this is worth a look: https://chibisov.github.io/drf-extensions/docs/#caching
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With