Added guard to cache handler so it doesn't loop forever