Skip to content

Commit da4a9f5

Browse files
Merge pull request #20 from coreweave/cpierre/caching
feat(nginx): tune caching thresholds for large images
2 parents cdddeb3 + 9cd0135 commit da4a9f5

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ CACHE_MAX_SIZE=${CACHE_MAX_SIZE:-32g}
102102

103103
# The cache directory. This can get huge. Better to use a Docker volume pointing here!
104104
# Set to 32gb which should be enough
105-
echo "proxy_cache_path /docker_mirror_cache levels=1:2 max_size=$CACHE_MAX_SIZE inactive=60d keys_zone=cache:10m use_temp_path=off;" > /etc/nginx/conf.d/cache_max_size.conf
105+
echo "proxy_cache_path /docker_mirror_cache levels=1:2 max_size=$CACHE_MAX_SIZE min_free=${CACHE_MIN_FREE:-1g} inactive=${CACHE_INACTIVE_TIME:-60d} keys_zone=cache:15m use_temp_path=off manager_threshold=${CACHE_MANAGER_THRESHOLD:-1000ms} manager_sleep=${CACHE_MANAGER_SLEEP:-250ms} manager_files=${CACHE_MANAGER_FILES:-100} loader_files=${CACHE_LOADER_FILES:-100} loader_threshold=${CACHE_LOADER_THRESHOLD:-200ms} loader_sleep=${CACHE_MANAGER_SLEEP:-50ms};" > /etc/nginx/conf.d/cache_max_size.conf
106106

107107
# Manifest caching configuration. We generate config based on the environment vars.
108108
echo -n "" >/etc/nginx/nginx.manifest.caching.config.conf

nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
317317
proxy_cache cache;
318318
# But we store the result with the cache key of the original request URI
319319
# so that future clients don't need to follow the redirect too
320-
proxy_cache_key $original_uri;
320+
proxy_cache_key $original_uri$slice_range;
321321
}
322322

323323
# by default, dont cache anything.

nginx.manifest.common.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
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+
slice 4m;
7+
proxy_cache_key $uri$slice_range;
8+
proxy_set_header Range $slice_range;
9+
proxy_http_version 1.1;
710
proxy_intercept_errors on;
811
error_page 301 302 307 = @handle_redirects;

0 commit comments

Comments
 (0)