fix: counting cache

This commit is contained in:
lelo 2025-12-25 20:46:41 +00:00
parent d3743d2685
commit 5015075694

10
app.py
View File

@ -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'