On the first push of a PR, Netlify takes the cache from the master branch and builds from that. However, after the first push of a PR, all subsequent pushes to that PR will use the branch specific cache. The problem arises when that second push happens quite quickly after the first push. There is a period of time after the first PR build where Netlify has to create the new branch cache and if the second push happens before this is created then it thinks there is a cache miss and then starts the entire build from scratch, fresh clone, install gems, node modules, etc.
I’d like to see the behaviour change to keeping the first lookup for the branch cache but if that misses then first revert to looking for the master cache before finally falling back to building from scratch. Doing that seems like a reasonable solution and even if your first PR added a node module or 2 for example then you are just reinstalling those again on a branch cache miss rather than everything.
We currently experience a number of cache misses every day on our builds and this would pretty much eliminate the problem. I’m sure a lot of others would benefit from this as well.