Bug description
When trailing slashes are enforced (URL::enforceTrailingSlashes()), custom invalidation rules with trailing slashes don't clear the cache.
Example config:
'collections' => [
'events' => [
'urls' => [
'/events/',
'/annual-meeting/',
],
],
],
It seems DefaultInvalidator tidies relative rules with withTrailingSlash: false, so /events/ becomes /events. Invalidation then does an exact match against the URL index, which stores the request path (e.g. /events/).
Relevant code:
// src/StaticCaching/DefaultInvalidator.php
->map(fn (string $rule) => URL::tidy($entry->site()->url().'/'.$rule, withTrailingSlash: false))
Note: DefaultUrlExcluder already normalizes via URL::tidy() on both sides, so exclusions handle this correctly — invalidation probably should too.
How to reproduce
- Enable trailing slashes
- Enable static caching
- Add invalidation rules like above for a collection
- Cache pages that use those URLs (e.g. pages with a collection tag pulling event data)
- Edit an entry in the events collection
- Cached pages at /events/ and /annual-meeting/ are not invalidated
Bug description
When trailing slashes are enforced (
URL::enforceTrailingSlashes()), custom invalidation rules with trailing slashes don't clear the cache.Example config:
It seems
DefaultInvalidatortidies relative rules withwithTrailingSlash: false, so/events/becomes/events. Invalidation then does an exact match against the URL index, which stores the request path (e.g./events/).Relevant code:
Note:
DefaultUrlExcluderalready normalizes viaURL::tidy()on both sides, so exclusions handle this correctly — invalidation probably should too.How to reproduce