Be smarter about dirty checking cached vs. uncached.

Doing an `||` check makes boolean values, numeric values, and string values possibly behave incorrectly in the dirty checking code.