CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 04 Sep 2025 07:09:52 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20100107020149
location: https://web.archive.org/web/20100107020149/https://github.com/simonw/ratelimitcache
server-timing: captures_list;dur=0.955015, exclusion.robots;dur=0.033434, exclusion.robots.policy;dur=0.014782, esindex;dur=0.017155, cdx.remote;dur=139.360815, LoadShardBlock;dur=1053.907920, PetaboxLoader3.resolve;dur=775.605809, PetaboxLoader3.datanode;dur=153.713666
x-app-server: wwwb-app218
x-ts: 302
x-tr: 1256
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app218; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 04 Sep 2025 07:09:53 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.7.61
x-archive-orig-date: Thu, 07 Jan 2010 02:01:48 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-etag: "5ca85cc2289ad4fa0476baca88942884"
x-archive-orig-x-runtime: 160ms
x-archive-orig-content-length: 22193
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Thu, 07 Jan 2010 02:01:49 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 07 Dec 2009 09:05:02 GMT", ; rel="prev memento"; datetime="Mon, 07 Dec 2009 09:05:02 GMT", ; rel="memento"; datetime="Thu, 07 Jan 2010 02:01:49 GMT", ; rel="next memento"; datetime="Thu, 18 Feb 2010 08:09:53 GMT", ; rel="last memento"; datetime="Mon, 23 Jun 2025 18:00:07 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 51_13_20100106224428_crawl101-c/51_13_20100107020027_crawl101.arc.gz
server-timing: captures_list;dur=0.829421, exclusion.robots;dur=0.034831, exclusion.robots.policy;dur=0.015270, esindex;dur=0.018176, cdx.remote;dur=43.691378, LoadShardBlock;dur=576.472305, PetaboxLoader3.resolve;dur=397.430863, PetaboxLoader3.datanode;dur=487.116043, load_resource;dur=442.404285
x-app-server: wwwb-app218
x-ts: 200
x-tr: 1149
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
simonw's ratelimitcache at master - GitHub
simonw / ratelimitcache
- Source
- Commits
- Network (4)
- Issues (1)
- Graphs
-
Branch:
master
-
Branches (1)
- master ✓
- Tags (0)
name | age | message | |
---|---|---|---|
![]() |
.gitignore | Wed Jan 07 11:16:10 -0800 2009 | Ignore pyc [simonw] |
![]() |
demo/ | Wed Jan 07 11:35:43 -0800 2009 | A small demo application [simonw] |
![]() |
ratelimitcache.py | Thu Sep 24 07:17:36 -0700 2009 | expire_after is now a method, not a property - ... [simonw] |
![]() |
readme.txt | Thu Jan 08 00:37:12 -0800 2009 | Installation note: you need to configure the CA... [simonw] |
readme.txt
ratelimitcache for Django ========================= By Simon Willison - https://simonwillison.net/ A rate limiter that uses Django's cache framework, with no requirement for a persistent data store. More information: https://simonwillison.net/2009/Jan/7/ratelimitcache/ Installation: Place the ratelimitcache.py on your Python path. Configure your CACHE_BACKEND setting. For best results, use the memcached backend - the other backends do not provide an atomic counter increment and so may suffer from less effective limiting due to race conditions. Cache documentation: https://docs.djangoproject.com/en/dev/topics/cache/ Demo: cd demo/ ./manage.py runserver 8008 Now browse to: https://localhost:8008/ https://localhost:8008/debug/ https://localhost:8008/login/ Basic usage (max 20 requests every 3 minutes): from ratelimitcache import ratelimit @ratelimit(minutes = 3, requests = 20) def myview(request): # ... return HttpResponse('...') Protecting a login form, i.e rate limit on IP address and attempted username: from ratelimitcache import ratelimit_post @ratelimit_post(minutes = 3, requests = 10, key_field = 'username') def login(request): # ... return HttpResponse('...') You can also use it directly in urls.py. Here's how you would use it with the login() view function provided by Django: from ratelimitcache import ratelimit_post from django.contrib.auth.views import login urlpatterns = patterns('', #... (r'^login/$', ratelimit_post( minutes = 3, requests = 10, key_field = 'username' )(login)), ) Custom behaviour, e.g. logging when the rate limit condition fails: from ratelimitcache import ratelimit from my_logging_app.models import Log import datetime, pprint class ratelimit_with_logging(ratelimit): def disallowed(self, request): Log.objects.create( ip_address = request.META.get('REMOTE_ADDR'), path = request.path, counters = pprint.pformat( self.get_counters(reqest) ), created = datetime.datetime.now() ) return HttpResponseForbidden('Rate limit exceeded') @ratelimit_with_logging(minutes = 3, requests = 20) def myview(request): # ... return HttpResponse('...')
This feature is coming soon. Sit tight!