Commit 0f8e5706 authored by fred's avatar fred

performance: strip piwik cookies, so requests are cached for everybody

parent 26882d73
import re
class StripPiwikCookieMiddleware(object):
# idea from http://djangosnippets.org/snippets/1772/
strip_re = re.compile(r'(_pk_[a-z0-9\.]+=.+?(?:; |$))')
def process_request(self, request):
try:
cookie = self.strip_re.sub('', request.META['HTTP_COOKIE'])
request.META['HTTP_COOKIE'] = cookie
except:
pass
......@@ -214,6 +214,9 @@ if DEBUG and DEBUG_TOOLBAR:
'INTERCEPT_REDIRECTS': False,
}
if ENABLE_PIWIK:
MIDDLEWARE_CLASSES += ('panikweb.middleware.StripPiwikCookieMiddleware',)
if STATSD_CLIENT != 'django_statsd.clients.null':
MIDDLEWARE_CLASSES = (
'django_statsd.middleware.GraphiteRequestTimingMiddleware',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment