File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,16 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
244
244
proxy_ignore_client_abort on ;
245
245
proxy_cache_revalidate on;
246
246
247
+ # Avoid conversion of HEAD method to GET
248
+ proxy_cache_convert_head off;
249
+ # HEAD requests are to be cached separately from GET, so they need a different cache key.
250
+ # To avoid a breaking change in cache keys (which would invalidate existing caches), we keep the normal URI
251
+ # for GET requests as key, but use a prefix for HEAD.
252
+ set $docker_proxy_cache_prefix "" ;
253
+ if ($request_method = HEAD) {
254
+ set $docker_proxy_cache_prefix "HEAD:" ;
255
+ }
256
+
247
257
# Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations.
248
258
proxy_hide_header Set-Cookie;
249
259
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
@@ -307,7 +317,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
307
317
proxy_cache cache;
308
318
# But we store the result with the cache key of the original request URI
309
319
# so that future clients don't need to follow the redirect too
310
- proxy_cache_key $original_uri ;
320
+ proxy_cache_key $docker_proxy_cache_prefix$ original_uri ;
311
321
}
312
322
313
323
# by default, dont cache anything.
Original file line number Diff line number Diff line change 3
3
add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type";
4
4
proxy_pass https://$targetHost;
5
5
proxy_cache cache;
6
- proxy_cache_key $uri;
6
+ proxy_cache_key $docker_proxy_cache_prefix$ uri;
7
7
proxy_intercept_errors on;
8
8
error_page 301 302 307 = @handle_redirects;
You can’t perform that action at this time.
0 commit comments