Tweaking the caching code so that it's better at caching transformations
that don't result in valid queries.