Fixes #143. Invalidate only the cache that is dirty but not the rest.