django-compression-middleware
django-compression-middleware copied to clipboard
Provide a way to disable compression per view
For some views (e.g. views generating already compressed file types like PDF, PNG, etc) it isn't worth trying to compress them. It would be useful to be able to exclude certain views from the middleware's automatic compression.
I have an idea - was poking around Django's docs, and suddenly realized that Django's @csrf_exempt decorator serves the same purpose as what we want to do here: prevent a piece of middleware from running against a specific view. So I'll dig into that and maybe we can do it the same way.