Ajax is taking 1sec to load in dev and 500ms in prod with Symfony2 with a really simple call :
Javascript :
$.ajax({
url: "{{ path('my_path') }}",
type: 'GET',
data: {x: x},
dataType: 'json',
}).done(function(res) {
});
Controller :
/**
* @Route("/my_path", name="my_path", condition="request.isXmlHttpRequest()")
* @Method("GET")
*/
public function myPathAction(Request $request)
{
return new JsonResponse('');
}
If I change the url in my ajax call by
url: "test.php"
With test.php :
return json_encode('');
In both case we are doing the same thing but accessing to a controller take 500ms in prod and accessing to "test.php" takes 20ms.
Why does Symfony takes that much time to access to the route and how can I make it faster ?