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
Configuration or annotation invalidation not working in Symfony 2.7.1 #224
Comments
This is weird. All tests succeed on Symfony 2.7.1. Can you show us how you invalidate And when add a breakpoint in |
I am manually invalidating the cache for a route called "booking" in the bookingUpdateAction() and bookingCreateAction() methods with:
|
I can also confirm that |
@benr77 can you try to reproduce the problem in a test and do a pull request that fails with symfony 2.7.1 please? i think the test is try to add your situation there so we see a failing test. that will be the best way to fix the problem. |
I have the same problem. I tried to debug it a bit and Varnish is never contacted. I suspect a problem in the matching of a request (especially with attributes and _route). I'll try to debug it a bit more. |
Thanks @tgalopin, keep us posted! |
Okay, I found my problem, but I'm not sure it's the same than @benr77: FOSHttpCacheBundle does not match I think it's not very clear in the documentation what status codes does For the moment I added the status in the configuration: |
hm, i think our reusing things tripps us here. for adding caching headers, it makes sense to ignore 204 because i can't think of a sane use case to return 204 to a GET request. but for active invalidation, i think all 2xx and 3xx status should be used. we want to invalidate whenever an operation worked out. i guess the critical bit is here: https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/master/EventListener/InvalidationSubscriber.php#L161 - we should somehow make that match logic more flexible, have a separate isCacheableStatus method maybe |
this should also be noted in the changelog. with master already being 2.0 we don't need to worry about BC breaks. |
I agree on invalidating all 2xx/3xx responses. But the RFC describes 204 as ‘cacheable by default’, too. So should we adhere to the RFC and put caching headers on that, too? |
oh, indeed rfc2616 was more restrictive: http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.4 - lets fix the default list but also fix the behaviour that invalidation happens on any status < 400. |
Okay, the situation is as follows.
|
According to the first post of @benr77, |
The systems are not completely identical:
|
do only 2xx invalidate or also 3xx? 3xx is also a successful state. |
I think the bundle should follow the Symfony |
ok, i got the naming wrong. but we surely want to invalidate when a POST is answered with a 3xx status code. we can use isRedirect() or just compare ourselves. |
Hello all. I have been reading all your responses but not sure I follow everything. Have you managed to find the problem that I reported? Is this something that is easily fixed? Do let me know if there's anything I can do to help. |
@benr77 Which HTTP status code does your |
@ddeboer It is a standard Symfony2 controller action, so in the updateAction() method, it performs a 302 redirect using the RedirectResponse() method
|
Thanks, that explains it: when invalidating content, we call This is a nasty problem though, and we’ll come up with a fix shortly. |
Fix #224. Invalidation was not triggered when the controller response had status code 204 or 302.
Fix #224. Invalidation was not triggered when the controller response had status code 204 or 302.
@ddeboer Thank you! I've updated and as far as I can tell all is now working as expected. I have everything operating correctly via YML config. Thanks everyone for helping resolve this so quickly! |
Hi,
I'm setting up this bundle on Symfony 2.7.1 using the Symfony2 proxy client and of course the Symfony2 HttpCache. If I manually set up invalidation rules in the controller action methods, it works fine and I can see the PURGE requests appearing in the web server logs and the cache is cleared successfully.
However, I cannot get any invalidation to work with the invalidation rules specified either in the YML or as Annotations.
Here is my config
As you can see I'm asking it to invalidate the "booking" route when the "booking_update" route is successfully requested. This appears to do nothing.
I have also tried in the BookingUpdateAction() method the annotation
@InvalidateRoute("booking")
I have the SensioFrameworkExtra bundle installed as per the docs.
I have also modified app/AppCache.php as follows:
Finally, here is my app_dev.php file
Can anyone shed any light on why the invalidation does not work unless I define it manually in the controller action method?
Alternatively, maybe this is a bug with Symfony 2.7.1
I'm running PHP 5.5.9 on Apache 2.4.7 on Linux Mint 17.1
Thanks
Ben
The text was updated successfully, but these errors were encountered: