
On Fri, Sep 14 2018, Jaroslav Klapalek wrote:
Adding timestamp to url for composing the graphs makes the url different -- thus forcing the website to ask for the graph again and do not use cached one. --- app.py | 2 +- templates/user.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app.py b/app.py index a597ad6..d662c00 100644 --- a/app.py +++ b/app.py @@ -53,7 +53,7 @@ def user(): count=db.coffee_count(uid, 0), stamp=time.time() ) - return render_template('user.html') + return render_template('user.html', stamp=time.time())
Tohle je jen workaround. Správné řešení je při generování grafu poslat hlavičku, která řekne prohlížeči, jak má nebo nemá výsledek cachovat. Nevím přesně, která hlavička je na to nejlepší, ani jak se nastavují hlavičky ve Flasku, ale něco se člověk snad dozví na https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
@app.route('/user/rename') diff --git a/templates/user.html b/templates/user.html index 51a41f6..f680629 100644 --- a/templates/user.html +++ b/templates/user.html @@ -28,7 +28,7 @@ <input id="username" type="text" name="name"> <input type="button" value="rename" onclick="renameUser()"> </form> - </p + </p>
Na tohle pošli samostatný patch. -M.
{% else %} <img src="{{ url_for('coffee_graph_history', _external=True, stamp=stamp) }}"> <img src="{{ url_for('coffee_graph_flavors_history', _external=True, stamp=stamp) }}"> -- 2.7.4
_______________________________________________ Coffee mailing list Coffee@rtime.felk.cvut.cz https://rtime.felk.cvut.cz/mailman/listinfo/coffee