cache: add trailing slash support
Tested by: pho
(cherry picked from commit e027e24bfac7dd311ddacaec73d6c42102069511)