Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikweb
Commits
0f8e5706
Commit
0f8e5706
authored
Sep 12, 2013
by
fred
Browse files
performance: strip piwik cookies, so requests are cached for everybody
parent
26882d73
Changes
2
Hide whitespace changes
Inline
Side-by-side
panikweb/middleware.py
0 → 100644
View file @
0f8e5706
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
panikweb/settings.py
View file @
0f8e5706
...
...
@@ -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'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment