JosephSilber / page-cache

Caches responses as static files on disk for lightning fast page loads.
MIT License
1.21k stars 118 forks source link

Fix cache if URL has trailing slash #109

Closed howdu closed 1 year ago

howdu commented 1 year ago

If the URL ends with a slash the explode contains an empty element at the end.

$segments = explode('/', ltrim($request->getPathInfo(), '/'));

Simple fix changing ltrim to trim

e.g: https://example.com/about-us/ VS: https://example.com/about-us

page-cache/about-us.html page-cache/about-us/pcindexpc.html

Nginx/apache will never read the latter.

Fixes issue: https://github.com/JosephSilber/page-cache/issues/35