From 2198ab9284fb709f4c6645c0070297afadde187e Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Fri, 5 Aug 2016 21:30:58 +0900 Subject: [PATCH] exclude OPTIONS requests from throttling Browsers send OPTIONS requests an API server prior to every request to check if CORS allowed, so rates are reached half time. We could just double the rate, but other clients don't send extra requests. --- rest_framework/throttling.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py index 57f24d13f..6d8b04f46 100644 --- a/rest_framework/throttling.py +++ b/rest_framework/throttling.py @@ -118,6 +118,9 @@ class SimpleRateThrottle(BaseThrottle): """ if self.rate is None: return True + + if request.method == 'OPTIONS': + return True self.key = self.get_cache_key(request, view) if self.key is None: