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'