Otherwise we run into situations where commits to stable branches
induce very long build times, as they have to basically build from
scratch but also invalidate the cache for future commits on the
master branch.
This commit also makes the cache folder branch-specific, but since
it's still limited to 1 GB of total cache size, we don't enable it
for non-master, as we would still run into issues with non-master
build invalidating the master cache.
(cherry picked from commit b021bdbf1f)