File cache for Git HTTP GET /info/refs
We know that GET /info/refs is a very common request, and that it dynamically generates two types of response that only change when the repo is updated. There is great potential for caching here.
What is difficult about this is dealing with concurrent pushes, for instance this scenario:
- push A reaches post-receive and kicks off
git upload-pack --advertise-refs
- push B reaches post-receive and kicks off
git upload-pack --advertise-refs
- advertise-refs from push B finishes and writes the cached response
- advertise-refs from push A finishes and overwrites the cached response
- result: push B is not visible in the cached GET /info/refs response
What is simplest way to prevent this problem?