Backport cache invalidation fix (#487) to 0.9.x
Possible fix for #929 ?