🐛 Fix caching headers on / in case of wizards

Revalidation header from ceade46dd7 was
overwriting custom header in case of active wizards, causing the browser
to cache HTML code with enabled wizards.

This fixes this by checking if the headers in question actually need to
be set and aren't already there.
This commit is contained in:
Gina Häußge committed 2019-07-02 12:44:29 +02:00
1 parent 2c6568acd1
commit 72167d14d2
1 file changed
+8 -1
+8 -1
View File
@@ -1143,7 +1143,14 @@ def check_lastmodified(lastmodified):
def add_revalidation_response_headers(response):
response.headers["Cache-Control"] = "no-cache, must-revalidate"
import werkzeug.http
cache_control = werkzeug.http.parse_dict_header(response.headers.get("Cache-Control", ""))
if "no-cache" not in cache_control:
cache_control["no-cache"] = None
if "must-revalidate" not in cache_control:
cache_control["must-revalidate"] = None
response.headers["Cache-Control"] = werkzeug.http.dump_header(cache_control)
return response