Commits

Dan Carroll committed 3e9937f

Adding caching for home page and blog entry list

  • Participants
  • Parent commits ab418cf

Comments (0)

Files changed (5)

mysite/blog/views.py

 from django.shortcuts import render_to_response, get_object_or_404
 from django.template import RequestContext
 from django.http import Http404
+from django.views.decorators.cache import cache_page
 from django.views.generic import date_based, list_detail, simple
+
 from mysite.blog.models import Entry
 from mysite.blog.paginator import InfinitePaginator
 from tagging.views import tagged_object_list
 import datetime
 #import re
 
+@cache_page(60 * 15)
 def blog_entry_list(request):
     queryset = Entry.objects.published_for_list()
 

mysite/deploy.py.template

     }
 }
 
+CACHE_BACKEND = 'dummy://' #'memcached://unix:/home/username/memcached.sock'
 TIME_ZONE = 'America/Los_Angeles'
 
 MEDIA_URL = ''

mysite/settings.py

 
 DATABASES = deploy.DATABASES
 
+CACHE_BACKEND = deploy.CACHE_BACKEND
 TIME_ZONE = deploy.TIME_ZONE
 LANGUAGE_CODE = 'en-us'
 USE_I18N = False
     'django.contrib.admindocs',
     'django.contrib.sitemaps',
     'south',
+    'memcache_status',
 )
 
 # Activity sync settings
     DEBUG_TOOLBAR_CONFIG = {
         'INTERCEPT_REDIRECTS': False,
     }
-
+    
     SEND_BROKEN_LINK_EMAILS = False
 
     # Match local network IPs to allow access from other machines
 from django.http import HttpResponse
 from django.shortcuts import render_to_response
 from django.template import RequestContext
+from django.views.decorators.cache import cache_page
 
 from mysite.blog.models import Entry
 from activitysync.models import Activity
 from blog.views import blog_entry_detail
 
+@cache_page(60 * 15)
 def index(request):
     # This logic is to support theme detection by Windows Live Writer.
     # It needs to see the actual post display, but it stupidly goes to the main
 South==0.7.3
 django-debug-toolbar==0.8.4
 django-disqus==0.3.4
+django-memcache-status==1.0.1
 django-tagging==0.3.1
 django-xmlrpc==0.1.2
 feedparser==4.1
 httplib2==0.6.0
 oauth2==1.2.0
+python-memcached==1.47
 python-twitter==0.8.1
 simplejson==2.1.2
 wsgiref==0.1.2