diff options
Diffstat (limited to 'docs/api-guide/throttling.md')
| -rw-r--r-- | docs/api-guide/throttling.md | 16 | 
1 files changed, 9 insertions, 7 deletions
| diff --git a/docs/api-guide/throttling.md b/docs/api-guide/throttling.md index 832304f1..3f668867 100644 --- a/docs/api-guide/throttling.md +++ b/docs/api-guide/throttling.md @@ -1,4 +1,4 @@ -<a class="github" href="throttling.py"></a> +source: throttling.py  # Throttling @@ -74,7 +74,7 @@ If you need to strictly identify unique client IP addresses, you'll need to firs  It is important to understand that if you configure the `NUM_PROXIES` setting, then all clients behind a unique [NAT'd](http://en.wikipedia.org/wiki/Network_address_translation) gateway will be treated as a single client. -Further context on how the `X-Forwarded-For` header works, and identifing a remote client IP can be [found here][identifing-clients]. +Further context on how the `X-Forwarded-For` header works, and identifying a remote client IP can be [found here][identifing-clients].  ## Setting up the cache @@ -83,9 +83,9 @@ The throttle classes provided by REST framework use Django's cache backend.  You  If you need to use a cache other than `'default'`, you can do so by creating a custom throttle class and setting the `cache` attribute.  For example:      class CustomAnonRateThrottle(AnonRateThrottle): -        cache = get_cache('alternate')  +        cache = get_cache('alternate') -You'll need to rememeber to also set your custom throttle class in the `'DEFAULT_THROTTLE_CLASSES'` settings key, or using the `throttle_classes` view attribute. +You'll need to remember to also set your custom throttle class in the `'DEFAULT_THROTTLE_CLASSES'` settings key, or using the `throttle_classes` view attribute.  --- @@ -147,15 +147,15 @@ For example, given the following views...      class ContactListView(APIView):          throttle_scope = 'contacts'          ... -     +      class ContactDetailView(ApiView):          throttle_scope = 'contacts'          ... -    class UploadView(APIView):         +    class UploadView(APIView):          throttle_scope = 'uploads'          ... -     +  ...and the following settings.      REST_FRAMEWORK = { @@ -178,6 +178,8 @@ To create a custom throttle, override `BaseThrottle` and implement `.allow_reque  Optionally you may also override the `.wait()` method.  If implemented, `.wait()` should return a recommended number of seconds to wait before attempting the next request, or `None`.  The `.wait()` method will only be called if `.allow_request()` has previously returned `False`. +If the `.wait()` method is implemented and the request is throttled, then a `Retry-After` header will be included in the response. +  ## Example  The following is an example of a rate throttle, that will randomly throttle 1 in every 10 requests. | 
