From 50150756949504af30cee3cef80adc66323e23ce Mon Sep 17 00:00:00 2001 From: lelo Date: Thu, 25 Dec 2025 20:46:41 +0000 Subject: [PATCH] fix: counting cache --- app.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app.py b/app.py index 2c14299..0dee807 100755 --- a/app.py +++ b/app.py @@ -799,6 +799,16 @@ def serve_file(subpath): else: cache = cache_other + # Plain HEAD requests (without X-Cache-Request) should not populate the cache. + # They are just probes and would otherwise turn the first real GET into a “cached hit”. + if request.method == 'HEAD' and not is_cache_request: + response = make_response('', 200) + response.headers['Content-Type'] = mime + response.headers['Content-Length'] = str(filesize) + response.headers['Accept-Ranges'] = 'bytes' + response.headers['Cache-Control'] = 'public, max-age=86400' + return response + # 4) Image and thumbnail handling first if mime.startswith('image/'): small = request.args.get('thumbnail') == 'true'