Skip to content

Use SHA as proxy cache KEY #97

@yashtheone29

Description

@yashtheone29

Problem:

           # For blob requests by digest, do cache, and treat redirects.
       location ~ ^/v2/(.*)/blobs/sha256:(.*) {
           set $docker_proxy_request_type "blob-by-digest";
           include "/etc/nginx/nginx.manifest.common.conf";
       }

       # For manifest requests by digest, do cache, and treat redirects.
       # These are some of the requests that DockerHub will throttle.
       location ~ ^/v2/(.*)/manifests/sha256:(.*) {
           set $docker_proxy_request_type "manifest-by-digest";
           include "/etc/nginx/nginx.manifest.common.conf";
       }
       
    In these two cases ,  cache key is URI :(`proxy_cache_key   $uri;`) and this treats below 2 blobs as different and consumes extra storage!

    1. my.docker.host/v2/someDockerImage1/blobs/sha256:74924e75d64523f42420d9b0617430fa955e49d835e663e6c838f0ed5209c8da
    2. my.docker.host/v2/someDockerImage2/blobs/sha256:74924e75d64523f42420d9b0617430fa955e49d835e663e6c838f0ed5209c8da

Solution:

Use SHA as KEY

```
 location ~ ^/v2/(.*)/blobs/(.*) {
        set $cache_key $2;
        proxy_pass https://$host;
        proxy_cache cache;
        proxy_cache_key $cache_key;
 ```

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions