Expression caching

improved version of #9006 (which was an improved version of #8942)
And this one should just set the `externalInput` flag on the `foo` filter, and `expect(parsed.constant).toBe(false)`.