Fix cache not invalidating correctly