Fix cache for programmatically altered views

#3952