adamchainz / django-browser-reload

Automatically reload your browser in development.
MIT License
516 stars 26 forks source link

django-browser-reload is incompatible with the GZip middleware #204

Open ghost opened 1 year ago

ghost commented 1 year ago

Description

Folks thanks for maintaining this package. It recently stopped working for a project of mine and I bisected back to it starting to use the DjangoGZip middleware.

The symptom is that the reloads stop happening. Potential solution to https://github.com/adamchainz/django-browser-reload/issues/68#issue-1143149766.

I solved it by not using the GZip middleware at dev time, but perhaps this is a matter of ordering the middleware differently?

A suggestion for guarding against this, if you deem it useful: django-browser-reload should inspect the middleware list and crash the development server on start with a helpful message if the gzip middleware is present (at the wrong place in the list?), unless ALLOW_BROKEN_GZIP_RELOAD=True.

Cheers.

adamchainz commented 1 year ago

Yes it’s an ordering issue. See step 5 of the instructions: https://github.com/adamchainz/django-browser-reload#installation

We could add a system check but it would have to be specific to GZipMiddleware and would miss other encoding middleware from third party packages. Maybe that’s okay. No need for a custom setting to silence it if we create a system check.