fabiocaccamo / django-maintenance-mode

:construction: :hammer_and_wrench: shows a 503 error page when maintenance-mode is on.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add no cache headers to response

mlissner opened this issue · comments

Django has a decorator called never_cache that ensures that requests are, umm, never cached. Caching is complicated, but I think this library should use this functionality to ensure that the maintenance mode is not cached. This way, when maintenance mode is disabled, the site will return quickly.

I just rewrote the middleware for my own project, and you can see how I implemented this there (it's a small, simple change).

Thanks for laying this groundwork. Great little middleware.

This is a good report, I will implement it as soon as possible.
Do you think that add_never_cache_headers should be added to the HttpResponseRedirect response too?
Do you know from which django version has been introduced add_never_cache_headers?

Do you think that add_never_cache_headers should be added to the HttpResponseRedirect response too?

I honestly don't know if temporary redirects ever get cached. My guess would be they don't, since we have permanent redirects which do, but I don't know.

Do you know from which django version has been introduced add_never_cache_headers?

Alas, I have no idea! I'm not even sure that it's a public method, actually. I found it while looking at the never_cache decorator, since the decorator couldn't be applied to a middleware. It's small though...you could implement it locally if you wanted, without much trouble.

Fixed with 0.4.2 version