Performance: Authentication guards
MEDIUM IMPACT
Authentication guards affect server response time and client perceived load by controlling access before rendering protected content.
<?php Route::middleware(['auth'])->group(function () { Route::get('/dashboard', function () { // Load dashboard view }); });
<?php Route::get('/dashboard', function () { if (!auth()->check()) { return redirect('/login'); } // Load dashboard view });
| Pattern | Server Processing | Response Delay | Client Impact | Verdict |
|---|---|---|---|---|
| Manual auth checks in routes | High (repeated checks) | Increased by ~20ms | Slower LCP | [X] Bad |
| Middleware auth guards | Optimized (centralized) | Minimal delay | Faster LCP | [OK] Good |