Performance: Conditional requests handling
MEDIUM IMPACT
This affects server response time and network load by reducing unnecessary data transfer when content is unchanged.
app.get('/data', (req, res) => { const data = getData(); const etag = generateETag(data); res.set('ETag', etag); if (req.headers['if-none-match'] === etag) { res.status(304).end(); } else { res.send(data); } });
app.get('/data', (req, res) => {
const data = getData();
res.send(data);
});| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Always send full response | N/A (server-side) | N/A | High network payload delays paint | [X] Bad |
| Use ETag with 304 Not Modified | N/A (server-side) | N/A | Minimal network payload speeds paint | [OK] Good |