summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-01-05 20:03:00 +0100
committerDan McGee <dan@archlinux.org>2012-01-05 20:03:00 +0100
commit6b16b9487a95118a6109a2c5119d430dc1192e80 (patch)
treea6ad637efb2cfd04bde7f241f91c693311432fb9
parent7b7dcfaa7c1b10d4f595a68e4136f30162930011 (diff)
downloadarchweb-6b16b9487a95118a6109a2c5119d430dc1192e80.tar.gz
archweb-6b16b9487a95118a6109a2c5119d430dc1192e80.tar.xz
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 <dan@archlinux.org>
-rw-r--r--devel/views.py14
-rw-r--r--main/models.py8
-rw-r--r--mirrors/utils.py4
-rw-r--r--packages/utils.py4
-rw-r--r--packages/views/__init__.py2
-rw-r--r--packages/views/signoff.py2
-rw-r--r--public/utils.py2
-rw-r--r--todolists/views.py2
8 files changed, 19 insertions, 19 deletions
diff --git a/devel/views.py b/devel/views.py
index 2e62200..35918d6 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -13,6 +13,7 @@ from django.template import loader, Context
from django.template.defaultfilters import filesizeformat
from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
+from django.utils.http import http_date
from main.models import Package, PackageDepend, PackageFile, TodolistPkg
from main.models import Arch, Repo
@@ -27,9 +28,9 @@ import operator
import pytz
import random
from string import ascii_letters, digits
+import time
@login_required
-@never_cache
def index(request):
'''the developer dashboard'''
if(request.user.is_authenticated()):
@@ -80,7 +81,6 @@ def index(request):
return direct_to_template(request, 'devel/index.html', page_dict)
@login_required
-@never_cache
def clock(request):
devs = User.objects.filter(is_active=True).order_by(
'first_name', 'last_name').select_related('userprofile')
@@ -98,7 +98,14 @@ def clock(request):
'utc_now': utc_now,
}
- return direct_to_template(request, 'devel/clock.html', page_dict)
+ response = direct_to_template(request, 'devel/clock.html', page_dict)
+ if not response.has_header('Expires'):
+ # why this works only with the non-UTC date I have no idea...
+ expire_time = now.replace(minute=utc_now.minute + 1,
+ second=0, microsecond=0)
+ expire_time = time.mktime(expire_time.timetuple())
+ response['Expires'] = http_date(expire_time)
+ return response
class ProfileForm(forms.Form):
email = forms.EmailField(label='Private email (not shown publicly):',
@@ -342,7 +349,6 @@ def new_user_form(request):
return direct_to_template(request, 'general_form.html', context)
@user_passes_test(lambda u: u.is_superuser)
-@never_cache
def admin_log(request, username=None):
user = None
if username:
diff --git a/main/models.py b/main/models.py
index c54e297..d72f2c0 100644
--- a/main/models.py
+++ b/main/models.py
@@ -201,14 +201,14 @@ class Package(models.Model):
def maintainers(self, maintainers):
self._maintainers = maintainers
- @cache_function(300)
+ @cache_function(1800)
def applicable_arches(self):
'''The list of (this arch) + (available agnostic arches).'''
arches = set(Arch.objects.filter(agnostic=True))
arches.add(self.arch)
return list(arches)
- @cache_function(300)
+ @cache_function(119)
def get_requiredby(self):
"""
Returns a list of package objects. An attempt will be made to keep this
@@ -254,7 +254,7 @@ class Package(models.Model):
trimmed.append(dep)
return trimmed
- @cache_function(300)
+ @cache_function(121)
def get_depends(self):
"""
Returns a list of dicts. Each dict contains ('dep', 'pkg', and
@@ -279,7 +279,7 @@ class Package(models.Model):
deps.append({'dep': dep, 'pkg': pkg, 'providers': providers})
return deps
- @cache_function(300)
+ @cache_function(125)
def base_package(self):
"""
Locate the base package for this package. It may be this very package,
diff --git a/mirrors/utils.py b/mirrors/utils.py
index 686ec58..f05ffc7 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -26,7 +26,7 @@ def annotate_url(url, delays):
url.delay = None
url.score = None
-@cache_function(300)
+@cache_function(123)
def get_mirror_statuses(cutoff=default_cutoff):
cutoff_time = datetime.datetime.utcnow() - cutoff
protocols = list(MirrorProtocol.objects.filter(is_download=True))
@@ -80,7 +80,7 @@ def get_mirror_statuses(cutoff=default_cutoff):
'urls': urls,
}
-@cache_function(300)
+@cache_function(117)
def get_mirror_errors(cutoff=default_cutoff):
cutoff_time = datetime.datetime.utcnow() - cutoff
errors = MirrorLog.objects.filter(
diff --git a/packages/utils.py b/packages/utils.py
index d4a9d8f..2a43a08 100644
--- a/packages/utils.py
+++ b/packages/utils.py
@@ -11,7 +11,7 @@ from main.utils import cache_function, groupby_preserve_order, PackageStandin
from .models import (PackageGroup, PackageRelation,
SignoffSpecification, Signoff, DEFAULT_SIGNOFF_SPEC)
-@cache_function(300)
+@cache_function(127)
def get_group_info(include_arches=None):
raw_groups = PackageGroup.objects.values_list(
'name', 'pkg__arch__name').order_by('name').annotate(
@@ -92,7 +92,7 @@ class Difference(object):
return False
-@cache_function(300)
+@cache_function(127)
def get_differences_info(arch_a, arch_b):
# This is a monster. Join packages against itself, looking for packages in
# our non-'any' architectures only, and not having a corresponding package
diff --git a/packages/views/__init__.py b/packages/views/__init__.py
index 9f24056..5be4833 100644
--- a/packages/views/__init__.py
+++ b/packages/views/__init__.py
@@ -5,7 +5,6 @@ from django.core.serializers.json import DjangoJSONEncoder
from django.http import HttpResponse, Http404
from django.shortcuts import get_object_or_404, redirect
from django.utils import simplejson
-from django.views.decorators.cache import never_cache
from django.views.decorators.http import require_POST
from django.views.decorators.vary import vary_on_headers
from django.views.generic.simple import direct_to_template
@@ -247,7 +246,6 @@ def arch_differences(request):
return direct_to_template(request, 'packages/differences.html', context)
@permission_required('main.change_package')
-@never_cache
def stale_relations(request):
relations = PackageRelation.objects.select_related('user')
pkgbases = Package.objects.all().values('pkgbase')
diff --git a/packages/views/signoff.py b/packages/views/signoff.py
index e57b4d9..e3daf0d 100644
--- a/packages/views/signoff.py
+++ b/packages/views/signoff.py
@@ -18,7 +18,6 @@ from ..utils import (get_signoff_groups, approved_by_signoffs,
PackageSignoffGroup)
@permission_required('main.change_package')
-@never_cache
def signoffs(request):
signoff_groups = sorted(get_signoff_groups(), key=attrgetter('pkgbase'))
for group in signoff_groups:
@@ -178,7 +177,6 @@ class SignoffJSONEncoder(DjangoJSONEncoder):
return super(SignoffJSONEncoder, self).default(obj)
@permission_required('main.change_package')
-@never_cache
def signoffs_json(request):
signoff_groups = sorted(get_signoff_groups(), key=attrgetter('pkgbase'))
data = {
diff --git a/public/utils.py b/public/utils.py
index 6566b8c..a40c9b5 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
diff --git a/todolists/views.py b/todolists/views.py
index d413ca4..e5cc082 100644
--- a/todolists/views.py
+++ b/todolists/views.py
@@ -47,7 +47,6 @@ def flag(request, list_id, pkg_id):
return redirect(todolist)
@login_required
-@never_cache
def view(request, list_id):
todolist = get_object_or_404(Todolist, id=list_id)
svn_roots = Repo.objects.order_by().values_list(
@@ -71,7 +70,6 @@ def list_pkgbases(request, list_id, svn_root):
mimetype='text/plain')
@login_required
-@never_cache
def todolist_list(request):
lists = get_annotated_todolists()
return direct_to_template(request, 'todolists/list.html', {'lists': lists})