Skip to content

Conversation

@js-murph
Copy link
Collaborator

What

Implements a caching strategy for the Go module proxy as described in https://proxy.golang.org/

Why

To add support for caching go modules

Tests

Implemented unit tests. In addition manual testing was performed as follows...

  1. Create a cachew.hcl:
memory {}

disk {
  root = "./state/cache"
}

gomod {
  proxy = "https://proxy.golang.org"
}
  1. Run the proxy ./cachewd --config cachew.hcl

  2. Manual verification...

$ time curl http://localhost:8080/github.com/alecthomas/kong/@latest
{"Version":"v1.13.0","Time":"2025-11-12T21:31:44Z","Origin":{"VCS":"git","URL":"https://github.com/alecthomas/kong","Hash":"d8de683664a2581e93717b7e4e8f4b55e4beeff4","Ref":"refs/tags/v1.13.0"}}
real	0m0.179s
user	0m0.006s
sys	0m0.011s

$ time curl http://localhost:8080/github.com/alecthomas/kong/@latest
{"Version":"v1.13.0","Time":"2025-11-12T21:31:44Z","Origin":{"VCS":"git","URL":"https://github.com/alecthomas/kong","Hash":"d8de683664a2581e93717b7e4e8f4b55e4beeff4","Ref":"refs/tags/v1.13.0"}}
real	0m0.033s
user	0m0.006s
sys	0m0.013s

@js-murph js-murph requested a review from alecthomas as a code owner January 20, 2026 05:00
@js-murph js-murph added the enhancement New feature or request label Jan 20, 2026
})

// Register a catch-all handler that filters for Go module proxy patterns
mux.Handle("GET /{path...}", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not be a sub-path? eg. /gomod/...?

I want to rethink how strategies get mounted, but in the interim I'd prefer to namespace them if possible. When we're mounting multiple strategies, it's hard to reason about how they'll interact.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can and should! I'll fix this.

@alecthomas
Copy link
Collaborator

I had another thought - I think we should enforce private repository blocking here, to prevent leaking to upstream public module proxies.

@alecthomas
Copy link
Collaborator

Which did also lead me to wonder whether we should be implementing a full proxy...but I think that's a question for another time.

@alecthomas
Copy link
Collaborator

Actually... https://github.com/goproxy/goproxy is explicitly designed to be embeddable, and has an extensible caching interface. Let's do some due diligence around whether this would be worthwhile to embed.

The advantage this could give us is the ability to cache private repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants