Performance: Route middleware
MEDIUM IMPACT
Route middleware affects the server response time and can indirectly impact the time until the page starts loading in the browser.
Route::middleware(['auth', 'log'])->group(function () { Route::get('/dashboard', function () { return view('dashboard'); }); });
Route::get('/dashboard', function () { return view('dashboard'); })->middleware(['auth', 'log']);
| Pattern | Server Processing | Middleware Calls | Response Delay | Verdict |
|---|---|---|---|---|
| Individual middleware per route | High | Multiple per route | Increased delay | [X] Bad |
| Grouped middleware for routes | Lower | Single group call | Reduced delay | [OK] Good |