Fix cache rewriting