Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

let's try fragment caching instead

  • Loading branch information...
commit 7c1a56a4e59c5ad6c3ff29a5de4ee3796cc8e74c 1 parent bd0be49
Justine Tunney authored
8 occupywallst/memcachedjson.py
View
@@ -12,7 +12,15 @@
except ImportError:
import json
+from django.core.cache import get_cache
from django.core.cache.backends.memcached import MemcachedCache
+from django.contrib.sessions.backends import cache as session_cache
+
+
+class SessionStore(session_cache.SessionStore):
+ def __init__(self, session_key=None):
+ self._cache = get_cache('json')
+ super(SessionStore, self).__init__(session_key)
class MemcachedCacheJSON(MemcachedCache):
13 occupywallst/settings.py
View
@@ -50,14 +50,14 @@
# need no goofy key prefixes
CACHES = {
'default': {
- 'BACKEND': 'occupywallst.memcachedjson.MemcachedCacheJSON',
- 'KEY_FUNCTION': lambda key, key_prefix, version: key,
+ 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': [
'127.0.0.1:11211',
],
},
- 'fast': {
- 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+ 'json': {
+ 'BACKEND': 'occupywallst.memcachedjson.MemcachedCacheJSON',
+ 'KEY_FUNCTION': lambda key, key_prefix, version: key,
'LOCATION': [
'127.0.0.1:11211',
],
@@ -88,7 +88,8 @@
LOGIN_REDIRECT_URL = '/'
MEDIA_URL = '/media/'
ADMIN_MEDIA_PREFIX = '/media/admin/'
-SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
+# SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
+SESSION_ENGINE = 'occupywallst.memcachedjson'
# change me in production
SECRET_KEY = 'oek(taazh36*h939oau#$%()dhueha39h(3zhc3##ev_jpfyd2'
@@ -115,12 +116,10 @@
MIDDLEWARE_CLASSES = [
'occupywallst.middleware.XForwardedForMiddleware',
- 'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.middleware.cache.FetchFromCacheMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'occupywallst.middleware.NeverCache',
3  occupywallst/templates/occupywallst/index.html
View
@@ -1,5 +1,6 @@
{% extends base %}
{% load ows %}
+{% load cache %}
{% block stylesheets %}
<style type="text/css">
@@ -8,6 +9,7 @@
{% endblock stylesheets %}
{% block content %}
+{% cache 60 index %}
<table style="width:100%"><tbody><tr><td id="left">
<section id="articles">
{% for article in articles %}
@@ -84,4 +86,5 @@
</p>
</section>
</td></tr></tbody></table>
+{% endcache %}
{% endblock content %}
Please sign in to comment.
Something went wrong with that request. Please try again.