I want to invalidate the HTTP cache in symfony2. I use the 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. But when I use a ESI include I with the controller() function (not path()) like:
{{ render_esi(controller('AcmeDemoBundle:Default:index')) }}
How do I get the url generated by the controller function? Or how can I invalidate the cached response of that esi request?