Improve cache checking