Use temporary redirects for HTTPS to prevent caching

This commit is contained in:
Taylor Helsper 2020-07-30 22:09:15 -05:00
parent 2bda1eca18
commit 8a1dbd6398

View File

@ -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'