mirror of
https://github.com/django/django.git
synced 2025-08-02 18:13:02 +00:00
Fixed #5791 -- Added early-bailout support for views (ETags and Last-modified).
This provides support for views that can have their ETag and/or Last-modified values computed much more quickly than the view itself. Supports all HTTP verbs (not just GET). Documentation and tests need a little more fleshing out (I'm not happy with the documentation at the moment, since it's a bit backwards), but the functionality is correct. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10114 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5ac154e065
commit
b203db6ec8
10 changed files with 388 additions and 4 deletions
17
tests/regressiontests/conditional_processing/views.py
Normal file
17
tests/regressiontests/conditional_processing/views.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
from django.views.decorators.http import condition
|
||||
from django.http import HttpResponse
|
||||
|
||||
from models import FULL_RESPONSE, LAST_MODIFIED, ETAG
|
||||
|
||||
@condition(lambda r: ETAG, lambda r: LAST_MODIFIED)
|
||||
def index(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
|
||||
@condition(last_modified_func=lambda r: LAST_MODIFIED)
|
||||
def last_modified(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
|
||||
@condition(etag_func=lambda r: ETAG)
|
||||
def etag(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
Loading…
Add table
Add a link
Reference in a new issue