File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,16 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
240240 proxy_ignore_client_abort on;
241241 proxy_cache_revalidate on;
242242
243+ # Avoid conversion of HEAD method to GET
244+ proxy_cache_convert_head off;
245+ # HEAD requests are to be cached separately from GET, so they need a different cache key.
246+ # To avoid a breaking change in cache keys (which would invalidate existing caches), we keep the normal URI
247+ # for GET requests as key, but use a prefix for HEAD.
248+ set $docker_proxy_cache_prefix "" ;
249+ if ( $request_method = HEAD) {
250+ set $docker_proxy_cache_prefix "HEAD:" ;
251+ }
252+
243253 # Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations.
244254 proxy_hide_header Set-Cookie;
245255 proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
@@ -303,7 +313,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
303313 proxy_cache cache;
304314 # But we store the result with the cache key of the original request URI
305315 # so that future clients don't need to follow the redirect too
306- proxy_cache_key $original_uri ;
316+ proxy_cache_key $docker_proxy_cache_prefix$ original_uri ;
307317 }
308318
309319 # by default, dont cache anything.
Original file line number Diff line number Diff line change 33 add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type";
44 proxy_pass https://$targetHost;
55 proxy_cache cache;
6- proxy_cache_key $uri;
6+ proxy_cache_key $docker_proxy_cache_prefix$ uri;
77 proxy_intercept_errors on;
88 error_page 301 302 307 = @handle_redirects;
You can’t perform that action at this time.
0 commit comments