mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-31 10:30:01 +03:00
Only preemptively check the cache on GET requests
This commit is contained in:
parent
cede7d86a3
commit
5e5de9c499
|
@ -97,6 +97,10 @@ class RetrieveModelMixin(object):
|
||||||
Should be mixed in with `SingleObjectAPIView`.
|
Should be mixed in with `SingleObjectAPIView`.
|
||||||
"""
|
"""
|
||||||
def retrieve(self, request, *args, **kwargs):
|
def retrieve(self, request, *args, **kwargs):
|
||||||
|
cached_object = self.check_preemptive_cache(request)
|
||||||
|
if cached_object:
|
||||||
|
return cached_object
|
||||||
|
|
||||||
queryset = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
filtered_queryset = self.filter_queryset(queryset)
|
filtered_queryset = self.filter_queryset(queryset)
|
||||||
self.object = self.get_object(filtered_queryset)
|
self.object = self.get_object(filtered_queryset)
|
||||||
|
|
|
@ -350,7 +350,6 @@ class APIView(View):
|
||||||
self.perform_authentication(request)
|
self.perform_authentication(request)
|
||||||
self.check_permissions(request)
|
self.check_permissions(request)
|
||||||
self.check_throttles(request)
|
self.check_throttles(request)
|
||||||
self.check_preemptive_cache(request)
|
|
||||||
|
|
||||||
# Perform content negotiation and store the accepted info on the request
|
# Perform content negotiation and store the accepted info on the request
|
||||||
neg = self.perform_content_negotiation(request)
|
neg = self.perform_content_negotiation(request)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user