Django Cookie Filter
Django middleware which removes all unwanted cookies - useful for improving cache hit ratios when analytics cookies interfere with caching.
Installation
Using pip:
$ pip install django-cookiefilter
Edit your Django project's settings module, and add the middleware to the start of MIDDLEWARE:
MIDDLEWARE = [
"cookiefilter.middleware.CookieFilterMiddleware",
# ...
]
[!NOTE] The middleware should be added before
UpdateCacheMiddleware, as it uses the value of HTTP_COOKIES which needs to be modified.
Configuration
Out of the box the standard Django cookie names will work without any other configuration. However
if your project uses different or additional cookie names, edit COOKIEFILTER_ALLOWED in your
project's settings module:
COOKIEFILTER_ALLOWED = [
"analytics",
"csrftoken",
"django_language",
"messages",
"sessionid",
]
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters