From a60801bb7dbc18080e7f6106bcf9c707d2801c9d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 11 Dec 2011 19:52:27 -0600 Subject: PyLint suggested cleanups Signed-off-by: Dan McGee --- public/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public') diff --git a/public/views.py b/public/views.py index 8fb60c78..bcae4bd7 100644 --- a/public/views.py +++ b/public/views.py @@ -8,7 +8,7 @@ from devel.models import MasterKey from main.models import Arch, Repo, Donor from mirrors.models import MirrorUrl from news.models import News -from utils import get_recent_updates +from .utils import get_recent_updates def index(request): pkgs = get_recent_updates() -- cgit v1.2.3-2-g168b From 9ddbe26e4c397c9a0b9fda73a0ce79bc658464d9 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 3 Jan 2012 15:00:49 -0600 Subject: 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 --- public/views.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'public') 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', -- cgit v1.2.3-2-g168b From 6b16b9487a95118a6109a2c5119d430dc1192e80 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 5 Jan 2012 13:03:00 -0600 Subject: Adjust page and content caching lengths and decorators Remove never_cache from many places now that we don't actually need it since we aren't caching by default. Adjust our cache_function decorator times be shorter values, and also randomize them a bit to make cache invalidations not all line up. Signed-off-by: Dan McGee --- public/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public') diff --git a/public/utils.py b/public/utils.py index 6566b8c4..a40c9b53 100644 --- a/public/utils.py +++ b/public/utils.py @@ -49,7 +49,7 @@ class RecentUpdate(object): if package.arch not in arches and not arches.add(package.arch): yield PackageStandin(package) -@cache_function(300) +@cache_function(62) def get_recent_updates(number=15): # This is a bit of magic. We are going to show 15 on the front page, but we # want to try and eliminate cross-architecture wasted space. Pull enough -- cgit v1.2.3-2-g168b