- Issue created by @krystalcode
- 🇵🇪Peru krystalcode
Implementing the quick - but less efficient - solution for now.
This is related to 🐛 Invalidate cached responses when new redirects are added Active in the Redirect module, we might want to follow the logic/solution decided there.
When a redirect is detected, the redirect entity is added to the response as a cacheable dependency. The router response then may be cached by, for example, Dynamic Page Cache. When that redirect is changed or deleted, the response is invalidated by the entity cache tags of the redirect.
However, because of the possibility of having redirect chains, a new redirect that affects the response may be created but the response may still be served from the cache - sending the user to the wrong page.
I have consistently reproduced this with Decouple Router, but on a project with some customizations. I'll post steps to reproduce on a clean project when I get some time. It should be reproducible by creating a redirect, make a call to the router with its path, ensure that it's a hit by dynamic page cache, add another redirect in the chain and confirm that the existing cached response is still served.
Add the redirect_list
cache tag to responses with a redirect trace, or analyze the cases and, for example, load redirects that could be affected by adding a new one in their chain and invalidate the entity cache tags for those redirects. Or, maybe add the cache tags for relevant paths to the response and invalidate those when a new redirect is added.
Ideally, implement the more accurate/efficient solution.
Active
2.0
Code
Implementing the quick - but less efficient - solution for now.