-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Cache is not invalidated for routes with container parameters #21426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this is a limitation, as otherwise every single change in your controller would cause a rebuild of the container. |
Could it be the other way around? Change in the container ( Before: # config.yml
parameters:
routing.type_slug: article|category After (added # config.yml
parameters:
routing.type_slug: article|category|comment I understand that it is trade-off between fast page load in development environment and cache freshness. If it can't be easily fixed, maybe mentioning it in the docs would be enough (as it isn't widely used feature). |
Adding the container class file as a resource of the main |
@ogizanagi I just verified that the patch fixes the issue, thanks! 👍 |
…er parameters changed (ogizanagi) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI][Router][DX] Invalidate routing cache when container parameters changed | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21426 | License | MIT | Doc PR | N/A Supersedes #21443 but only for master. Indeed, this implementation uses a new feature: a `ContainerParametersResource` which compares cached containers parameters (collected at some point, here by the `Router`) with current ones in the container. On the contrary of the previous PR targeting 2.7, this will only invalidate routing cache when parameters actually used in the routes changed and will avoid always rebuilding the routing cache when the container is rebuilt, just to catch the edge case of someone modifying a parameter. Commits ------- fad4d9e [DI][Router][DX] Invalidate routing cache when container parameters changed
While using a
@Route
annotation in the controller, thedev
cache is properly invalidated, if the route requirements are written directly in the annotation. But when using container parameters in requirements, the cache is not invalidated automatically and you need to deletecache/dev
directory manually.See the example: If another option is added to config, the route is not matched until the cache directory is manually deleted:
The text was updated successfully, but these errors were encountered: