From 8a1dbd63982e5ccd7e4d81903757baff0e12fb4d Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Thu, 30 Jul 2020 22:09:15 -0500 Subject: [PATCH] Use temporary redirects for HTTPS to prevent caching --- rootfs/standard/var/www/mynode/mynode.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index 4b52fed3..a86bfd4c 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -847,12 +847,17 @@ def before_request(): if is_https_forced(): if not request.is_secure: url = request.url.replace('http://', 'https://', 1) - code = 301 + code = 302 + app.logger.info("Redirecting to HTTPS ({})".format(url)) return redirect(url, code=code) # Disable browser caching @app.after_request def set_response_headers(response): + # Prevents 301 from saving forever + response.headers['Cache-Control'] = 'no-store' + + # No Caching #response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' #response.headers['Pragma'] = 'no-cache' #response.headers['Expires'] = '0'