Performance: Cookie handling
MEDIUM IMPACT
Cookie handling affects page load speed by adding data to HTTP headers and can impact interaction responsiveness if cookies are large or frequently accessed.
<?php // Setting minimal cookie with only needed data return response('Hello')->cookie('prefs', json_encode(['theme' => 'dark']));
<?php // Setting large cookie with unnecessary data return response('Hello')->cookie('prefs', json_encode(['theme' => 'dark', 'layout' => 'grid', 'notifications' => true, 'extra' => str_repeat('x', 2000)]));
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large cookies with unnecessary data | N/A | N/A | N/A | [X] Bad |
| Minimal cookies with only needed data | N/A | N/A | N/A | [OK] Good |
| Multiple cookie reads per request | N/A | N/A | N/A | [X] Bad |
| Single cookie parse and reuse | N/A | N/A | N/A | [OK] Good |