Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SHA as proxy cache KEY #97

Open
yamarane opened this issue Jul 7, 2021 · 1 comment
Open

Use SHA as proxy cache KEY #97

yamarane opened this issue Jul 7, 2021 · 1 comment

Comments

@yamarane
Copy link

yamarane commented Jul 7, 2021

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;
 ```
@hishamanver
Copy link
Contributor

i definitely think this should be implemented. this allows the cache to use dockers inherent ability to reuse layers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants