'Laravel Json Reponse running really slow

My code suddenly started working really slow. I don;t see any reason, noting was changed or updated.

return response()->json([
            'status' => 'success',
            'message' => 'Some message',
            'result' => []
        ], 200);

Funny is that if I replace in the controller that same piece of code with something like.

header('Content-Type: application/json; charset=utf-8');
echo json_encode([
                'status' => 'success',
                'message' => 'Some message',
                'result' => []
            ]);

The response time is like 20 times faster, even more. So what could be the issue ? And why did it happened suddenly, it was working fine before.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source