diff --git a/pygit/pygit.py b/pygit/pygit.py
index 3934fb5..c3fb008 100644
--- a/pygit/pygit.py
+++ b/pygit/pygit.py
@@ -81,14 +81,7 @@ def blame(rid,file,branch='master'):
return [(ci.id_abbrev,ci.author.name,date(ci.authored_date),ci.message[:40],''.join(l[:40])) for ci,l in bl]
def cached_diff(repo,c1,c2):
- key = 'git-diff-%s' % (hash(repo.path) + hash(c1) + hash(c2))
- r = cache.get(key)
- if r:
- return r
- else:
- r = Commit.diff(repo,c1,c2)
- cache.set(key,r,3*60*60)
- return r
+ return Commit.diff(repo,c1,c2)
def diff_all(rid,cid1,cid2=None):
r = open_repo(rid)
diff --git a/pygit/views.py b/pygit/views.py
index 79b4080..c18ed46 100644
--- a/pygit/views.py
+++ b/pygit/views.py
@@ -6,6 +6,7 @@ from os.path import dirname,join
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.core.cache import cache
+from django.views.decorators.cache import cache_page
import pygit
from chart import Chart
@@ -125,6 +126,7 @@ def format_diff(diff):
lines = map(escape,data.split('\n'))
return diff[0], '\n'.join(map(format_line,lines)), diff[2]
+@cache_page(60*60)
def diff_file(request,rid,branch,cid,path):
commit = pygit.commit(rid,cid)
message = commit.message
@@ -148,6 +150,7 @@ def diff_file(request,rid,branch,cid,path):
'diffs': ds},
request)
+@cache_page(60*60)
def diff_all(request,rid,branch,cid):
commit = pygit.commit(rid,cid)
message = commit.message
diff --git a/settings.py b/settings.py
index e2891ed..b3a26a2 100644
--- a/settings.py
+++ b/settings.py
@@ -18,7 +18,7 @@ DATABASE_PASSWORD = 'dJang0' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
-# CACHE_BACKEND='file:///tmp/django'
+CACHE_BACKEND='file:///tmp/django'
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE