changeset 8fa965f705f6 in www.tryton.org:default
details: https://hg.tryton.org/www.tryton.org?cmd=changeset;node=8fa965f705f6
description:
Add scheme to cache key prefix
As canonical url depends on the scheme, the rendered pages should be
cached
per scheme.
diffstat:
app.py | 39 ++++++++++++++++++++++-----------------
1 files changed, 22 insertions(+), 17 deletions(-)
diffs (164 lines):
diff -r 34c591fb86b1 -r 8fa965f705f6 app.py
--- a/app.py Mon Jan 13 13:05:06 2020 +0100
+++ b/app.py Thu Jan 16 13:28:48 2020 +0100
@@ -122,6 +122,11 @@
return url_for(*args, **kwargs)
+def cache_key_prefix_view():
+ scheme = 'https' if request.is_secure else 'http'
+ return 'view/%s/%s' % (scheme, request.path)
+
+
LinkHeader = namedtuple(
'LinkHeader', ['endpoint', 'values', 'params'])
@@ -240,7 +245,7 @@
@app.route('/')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def index():
return render_template(
@@ -474,7 +479,7 @@
@app.route('/success-stories')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def success_stories():
cases = sorted(
@@ -488,7 +493,7 @@
@app.route('/success-stories/<story>')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def success_story(story):
cases = [c for c in CASES if c.story or c.name == story]
@@ -512,7 +517,7 @@
@app.route('/download')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def download():
return render_template('download.html')
@@ -524,14 +529,14 @@
@app.route('/forum')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def forum():
return render_template('forum.html')
@app.route('/presentations')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def presentations():
return render_template('presentations.html')
@@ -543,7 +548,7 @@
@app.route('/events/<event>')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def event(event):
class Day:
@@ -604,7 +609,7 @@
@app.route('/contribute')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def contribute():
return render_template('contribute.html')
@@ -616,14 +621,14 @@
@app.route('/develop')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def develop():
return render_template('develop.html')
@app.route('/foundation')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def foundation():
return render_template('foundation.html')
@@ -646,7 +651,7 @@
@app.route('/supporters')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def supporters():
def url(supporter, start):
@@ -712,7 +717,7 @@
@app.route('/donate')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def donate():
return render_template('donate.html',
@@ -726,21 +731,21 @@
@app.route('/donate/thanks')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def donate_thanks():
return render_template('donate_thanks.html')
@app.route('/donate/cancel')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def donate_cancel():
return render_template('donate_cancel.html')
@app.route('/service-providers')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def service_providers():
shuffle(PROVIDERS)
@@ -753,7 +758,7 @@
@app.route('/service-providers/start')
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def service_providers_start():
return render_template('service_providers_start.html')
@@ -786,7 +791,7 @@
@app.errorhandler(HTTPStatus.NOT_FOUND)
[email protected]()
[email protected](key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
def not_found(error):
return render_template(