Performance: Why routing maps URLs to logic
MEDIUM IMPACT
Routing affects how quickly the server can match a URL to the correct code, impacting server response time and initial page load speed.
Route::get('/home', [HomeController::class, 'index']); Route::get('/profile', [ProfileController::class, 'show']);
Route::get('/{any}', function () { // Complex logic inside route closure sleep(1); // Simulate slow processing return view('welcome'); })->where('any', '.*');
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Catch-all route with closure logic | N/A (server-side) | N/A | N/A | [X] Bad |
| Explicit routes with controller methods | N/A (server-side) | N/A | N/A | [OK] Good |