From f17dadd5a35489768d3735a6148e53615d0a4445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Ny=CC=81vlt?= Date: Mon, 21 Aug 2023 10:43:25 +0200 Subject: [PATCH] Improve caching --- view/app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/view/app.py b/view/app.py index 28cd3dd..8ce5868 100644 --- a/view/app.py +++ b/view/app.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 import sqlite3 -from flask import Flask, request, render_template, g, send_from_directory +from flask import Flask, make_response, request, render_template, g, send_from_directory from flask_paginate import Pagination, get_page_parameter import confuse import re @@ -83,7 +83,7 @@ def index(): ) diffs = db.fetchall() - return render_template( + html = render_template( "./index.html", diffs=diffs, page=page, @@ -93,6 +93,11 @@ def index(): expand_diffs=expand_diffs, ) + res = make_response(html) + res.cache_control.max_age = 60 + res.cache_control.public = True + return res + @app.route("/article/") def article_detail(article_id: str):