Track Page Response Time using Laravel

if u have ever faced need for Page Loading Tracker using Laravel then this article will be helpful for you.

you can create below function in Middleware of your Laravel Application to calculate page response time

public function terminate($request, $response) {

$response_time = microtime(true) — LARAVEL_START;

$response_time = round($response_time, 2);

}

variable $response_time has the exact value of page execution time which one of your application’s user have faced.

thats it.

i have tried this option with Laravel 5,6,7. and it is working.

although Laravel gives us Telescope with > Laravel 5.7. which did the job. but this could be helpful with lower versions of laravel

this will help you to get knowledge of your users experience which they got on your website. in terminate() you can also have access Session/Auth ‘s properties.

--

--