improve(?) caching - vary header should not contain "cookie" for assets
This commit is contained in:
parent
ea20a19339
commit
69f68f43e9
1 changed files with 5 additions and 4 deletions
|
@ -37,6 +37,7 @@ app.config['DATABASE_URL'] = environ.get("DATABASE_CONNECTION_POOL_URL",environ.
|
||||||
|
|
||||||
app.config['SECRET_KEY'] = environ.get('MASTER_KEY')
|
app.config['SECRET_KEY'] = environ.get('MASTER_KEY')
|
||||||
app.config["SERVER_NAME"] = environ.get("DOMAIN").strip()
|
app.config["SERVER_NAME"] = environ.get("DOMAIN").strip()
|
||||||
|
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 60*10
|
||||||
|
|
||||||
app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower()
|
app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower()
|
||||||
app.config["VERSION"] = "1.0.0"
|
app.config["VERSION"] = "1.0.0"
|
||||||
|
@ -213,6 +214,9 @@ def before_request():
|
||||||
|
|
||||||
g.timestamp = int(time.time())
|
g.timestamp = int(time.time())
|
||||||
|
|
||||||
|
#do not access session for static files
|
||||||
|
if request.path.startswith("/assets"): return
|
||||||
|
|
||||||
session.permanent = True
|
session.permanent = True
|
||||||
|
|
||||||
ua_banned, response_tuple = get_useragent_ban_response(
|
ua_banned, response_tuple = get_useragent_ban_response(
|
||||||
|
@ -254,13 +258,10 @@ def after_request(response):
|
||||||
print(e)
|
print(e)
|
||||||
abort(500)
|
abort(500)
|
||||||
|
|
||||||
response.headers.remove("Cache-Control")
|
|
||||||
response.headers.add("Cache-Control", "public, max-age=600")
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@app.route("/<path:path>", subdomain="www")
|
@app.route("/<path:path>", subdomain="www")
|
||||||
def www_redirect(path):
|
def www_redirect(path):
|
||||||
|
|
||||||
return redirect(f"https://{app.config['SERVER_NAME']}/{path}")
|
return redirect(f"https://{app.config['SERVER_NAME']}/{path}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue