Performance: res.set for response headers
MEDIUM IMPACT
Setting response headers affects how the browser processes and caches the response, impacting load speed and rendering behavior.
app.get('/data', (req, res) => { res.set({ 'Cache-Control': 'public, max-age=3600', 'Content-Type': 'application/json' }); res.send(JSON.stringify({ message: 'Hello' })); });
app.get('/data', (req, res) => { res.set('Cache-Control', 'no-cache'); res.set('Content-Type', 'application/json'); res.send(JSON.stringify({ message: 'Hello' })); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No caching headers (Cache-Control: no-cache) | N/A | N/A | Higher due to repeated downloads | [X] Bad |
| Proper caching headers (Cache-Control: public, max-age=3600) | N/A | N/A | Lower due to cached resources | [OK] Good |