Expression caching

improved version of #9006 (which was an improved version of #8942)
Does this need `newInputValue && ` to handle null/undefined like the one below?