Do not cache moving targets like branches, fixes #1242