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 @@ -240,6 +240,16 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
240
240
proxy_ignore_client_abort on ;
241
241
proxy_cache_revalidate on;
242
242
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
+
243
253
# Hide/ignore headers from caching. S3 especially likes to send Expires headers in the past in some situations.
244
254
proxy_hide_header Set-Cookie;
245
255
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
@@ -303,7 +313,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
303
313
proxy_cache cache;
304
314
# But we store the result with the cache key of the original request URI
305
315
# 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 ;
307
317
}
308
318
309
319
# 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