diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-10-29 17:00:20 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-10-29 17:00:20 +0000 |
| commit | f12e3243326a2b6b0d09206b373b34e028eab25c (patch) | |
| tree | 706dab0c8455592749216f2ca724bdc1ec178c98 /django/views | |
| parent | 67d490a61dc5ee42b972f6c64bf589fbfc8db83f (diff) | |
Fixed #612 - added cache control headers (thanks, hugo)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1020 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/views')
| -rw-r--r-- | django/views/decorators/cache.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/django/views/decorators/cache.py b/django/views/decorators/cache.py index 09f9a0139f..f86372cf4e 100644 --- a/django/views/decorators/cache.py +++ b/django/views/decorators/cache.py @@ -10,8 +10,24 @@ example, as that is unique across a Django project. Additionally, all headers from the response's Vary header will be taken into account on caching -- just like the middleware does. """ +import re from django.utils.decorators import decorator_from_middleware +from django.utils.cache import patch_cache_control from django.middleware.cache import CacheMiddleware cache_page = decorator_from_middleware(CacheMiddleware) + +def cache_control(**kwargs): + + def _cache_controller(viewfunc): + + def _cache_controlled(request, *args, **kw): + response = viewfunc(request, *args, **kw) + patch_cache_control(response, **kwargs) + return response + + return _cache_controlled + + return _cache_controller + |
