symfony - How do I invalidate cache for a controller url? -
i want invalidate http cache in symfony2. use following method:
protected function invalidatecache($url) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_customrequest, 'purge'); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_header, true); curl_exec($ch); $status = curl_getinfo($ch, curlinfo_http_code); curl_close($ch); return $status == 200; }
that works, no problem. when use esi include controller() function (not path()) like:
{{ render_esi(controller('acmedemobundle:default:index')) }}
how url generated controller function? or how can invalidate cached response of esi request?
so here how it: don't.
the reason why wanted use controller() function instead path() because symfony protect url controller() unauthorised requests. should use path() , prefix urls "esi/" , protect url in security.yml.
//app/config/security.yml security: # // --- access_control: - { path: ^/esi/.*, roles: is_authenticated_anonymously, ip: 127.0.0.1 }
if want clear cache use url would.
thank @jongotlin on twitter helping me this.
Comments
Post a Comment