Cache: better fix for #5860 introduced in #5863

Cache: better fix for #5860 introduced in #5863