Skip to content

Commit

Permalink
Set max-age in thumbnails endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Nov 12, 2023
1 parent b4c508e commit fa59113
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/blueprints/thumbnails/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fa59113

Please sign in to comment.