store per branch cache

With these changes we will store the cache for every branch, not just master. If a branch does not yet have a cache, we try to fetch the cache for the master branch instead.