Fix cache undefined verification.

In some situations, the variable "cache" was undefined. A check was made before use.