From fa59113cd3ce70f1bb69bfc2013c5f8ce7ab884e Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 12 Nov 2023 16:18:20 +0000 Subject: [PATCH] Set max-age in thumbnails endpoint --- app/blueprints/thumbnails/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/blueprints/thumbnails/__init__.py b/app/blueprints/thumbnails/__init__.py index 589708ea..aa260e08 100644 --- a/app/blueprints/thumbnails/__init__.py +++ b/app/blueprints/thumbnails/__init__.py @@ -100,5 +100,9 @@ def make_thumbnail(img, level): cache_filepath = os.path.join(output_dir, img) source_filepath = find_source_file(img) - resize_and_crop(source_filepath, cache_filepath, (w, h)) - return send_file(cache_filepath) + if not os.path.isfile(cache_filepath): + resize_and_crop(source_filepath, cache_filepath, (w, h)) + + res = send_file(cache_filepath) + res.cache_control.max_age = 7*24*60*60 + return res