diff options
author | Dan McGee <dan@archlinux.org> | 2012-01-03 15:00:49 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-01-03 15:00:49 -0600 |
commit | 9ddbe26e4c397c9a0b9fda73a0ce79bc658464d9 (patch) | |
tree | 5be18c7c0e07a602860500962fc5cd121a3024a2 | |
parent | 5a91a246a848248eb8ec9d9402791c34e5ca0f6b (diff) |
Add a few cache headers and minor feed caching back in
Now that we aren't using the middleware, add cache headers on our
primary pages so we can prevent some repeat traffic, and cache all feeds
for five minutes.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | public/views.py | 7 | ||||
-rw-r--r-- | urls.py | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/public/views.py b/public/views.py index bcae4bd7..66c3a74f 100644 --- a/public/views.py +++ b/public/views.py @@ -1,6 +1,7 @@ from django.conf import settings from django.contrib.auth.models import User from django.http import Http404 +from django.views.decorators.cache import cache_control from django.views.generic import list_detail from django.views.generic.simple import direct_to_template @@ -10,6 +11,7 @@ from mirrors.models import MirrorUrl from news.models import News from .utils import get_recent_updates +@cache_control(max_age=300) def index(request): pkgs = get_recent_updates() context = { @@ -33,6 +35,7 @@ USER_LISTS = { }, } +@cache_control(max_age=300) def userlist(request, user_type='devs'): users = User.objects.order_by( 'first_name', 'last_name').select_related('userprofile') @@ -50,12 +53,14 @@ def userlist(request, user_type='devs'): context['users'] = users return direct_to_template(request, 'public/userlist.html', context) +@cache_control(max_age=300) def donate(request): context = { 'donors': Donor.objects.filter(visible=True).order_by('name'), } return direct_to_template(request, 'public/donate.html', context) +@cache_control(max_age=300) def download(request): qset = MirrorUrl.objects.select_related('mirror', 'protocol').filter( protocol__is_download=True, @@ -71,6 +76,7 @@ def download(request): template_object_name="mirror_url", extra_context=context) +@cache_control(max_age=300) def feeds(request): context = { 'arches': Arch.objects.all(), @@ -78,6 +84,7 @@ def feeds(request): } return direct_to_template(request, 'public/feeds.html', context) +@cache_control(max_age=300) def keys(request): context = { 'keys': MasterKey.objects.select_related('owner', 'revoker', @@ -27,12 +27,12 @@ urlpatterns = [] # Feeds patterns, used later feeds_patterns = patterns('', (r'^$', 'public.views.feeds', {}, 'feeds-list'), - (r'^news/$', NewsFeed()), - (r'^packages/$', PackageFeed()), + (r'^news/$', cache_page(300)(NewsFeed())), + (r'^packages/$', cache_page(300)(PackageFeed())), (r'^packages/(?P<arch>[A-z0-9]+)/$', - PackageFeed()), + cache_page(300)(PackageFeed())), (r'^packages/(?P<arch>[A-z0-9]+)/(?P<repo>[A-z0-9\-]+)/$', - PackageFeed()), + cache_page(300)(PackageFeed())), ) # Sitemaps |