avoid invalidaing the cache unless necessary
obey strict parameter
Merge pull request #4749 from dimagi/strict-domain

avoid invalidaing the cache unless necessary