Reputation: 33
I have a Django project and API view implemented with the Rest framework. I'm caching it using the @cache_page decorator but I need to implement a cache invalidation and I'm not seeing how to do that - do I need a custom decorator?
The problem: The view checks the access of the API KEY and it caches it from the previous access check but, if the user changes the API KEY before the cache expires, the view will return an OK status of the key that no longer exists.
Upvotes: 1
Views: 781
Reputation: 168834
Yes, you'll need a cache decorator that takes the authentication/user context into account. cache_page()
only works for GET requests, and keys based on the URL alone.
Better yet, though,
cache_page()
.Upvotes: 1