summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-12-14 22:06:26 +0100
committerDan McGee <dan@archlinux.org>2013-12-14 22:06:26 +0100
commit0b0e2b9d2aabd1c34f742e6525ee075751600e37 (patch)
treecd7bd988432c9caf189e6397d6cfc7de97cb68eb
parent5d74a99c6b8fbbd19ad441a74d835382025da522 (diff)
downloadarchweb-0b0e2b9d2aabd1c34f742e6525ee075751600e37.tar.gz
archweb-0b0e2b9d2aabd1c34f742e6525ee075751600e37.tar.xz
Fix some caching issues on the front page
The return value from get_recent_updates() was too big for memcached due to all the attached objects, so the cache never actually worked. This sucks, because we ended up doing all the work in this function and most of the time we didn't use it because template fragment caching kicked in. Remove the cache_function decorator from this method, and instead implement delayed calling of the function so we don't compute values we aren't going to use. Template fragment caching will help us in most cases. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--public/utils.py3
-rw-r--r--public/views.py8
-rw-r--r--templates/public/index.html2
3 files changed, 7 insertions, 6 deletions
diff --git a/public/utils.py b/public/utils.py
index fcfd0f7..1109188 100644
--- a/public/utils.py
+++ b/public/utils.py
@@ -2,7 +2,7 @@ from collections import defaultdict
from operator import attrgetter
from main.models import Arch, Repo, Package
-from main.utils import cache_function, groupby_preserve_order, PackageStandin
+from main.utils import groupby_preserve_order, PackageStandin
class RecentUpdate(object):
def __init__(self, packages):
@@ -58,7 +58,6 @@ class RecentUpdate(object):
return "RecentUpdate '%s %s' <%d packages>" % (
self.pkgbase, self.version, len(self.packages))
-@cache_function(62)
def get_recent_updates(number=15, testing=True, staging=False):
repos = Repo.objects.all()
if not testing:
diff --git a/public/views.py b/public/views.py
index f79c8f3..3b23bd4 100644
--- a/public/views.py
+++ b/public/views.py
@@ -20,12 +20,14 @@ from .utils import get_recent_updates
@cache_control(max_age=300)
def index(request):
if request.user.is_authenticated():
- pkgs = get_recent_updates(testing=True, staging=True)
+ def updates():
+ return get_recent_updates(testing=True, staging=True)
else:
- pkgs = get_recent_updates()
+ def updates():
+ return get_recent_updates()
context = {
'news_updates': News.objects.order_by('-postdate', '-id')[:15],
- 'pkg_updates': pkgs,
+ 'pkg_updates': updates,
}
return render(request, 'public/index.html', context)
diff --git a/templates/public/index.html b/templates/public/index.html
index c5924ab..58dd372 100644
--- a/templates/public/index.html
+++ b/templates/public/index.html
@@ -105,7 +105,7 @@
</div>
{% endcache %}
-{% cache 59 main-page-right secure %}
+{% cache 115 main-page-right secure %}
<div id="nav-sidebar" class="widget">
<h4>Documentation</h4>