A utility function to detect when you should invalidate your cached data