Performance: Token management
MEDIUM IMPACT
Token management affects page load speed and interaction responsiveness by controlling how authentication tokens are stored, validated, and refreshed in the frontend and backend.
// Use Laravel Sanctum or Passport with HttpOnly cookies // Backend manages token refresh automatically // JavaScript example fetch('/api/data', { credentials: 'include' });
// Storing token in localStorage and sending it with every request manually // No token refresh logic // JavaScript example localStorage.setItem('auth_token', token); fetch('/api/data', { headers: { 'Authorization': 'Bearer ' + localStorage.getItem('auth_token') } });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual token handling with localStorage | Minimal | 0 | Low | [X] Bad |
| HttpOnly cookie token management with Laravel Sanctum | Minimal | 0 | Low | [OK] Good |