Fix bug in detecting expired cache