In Express.js, req.fresh is true when the response is still fresh in the client’s cache — the cached copy still matches your validators. Then you can send 304 Not Modified instead of the full body.
Express compares conditional request headers (If-None-Match, If-Modified-Since) with response validators you set (ETag, Last-Modified). If the client sends Cache-Control: no-cache, req.fresh is false so a full response is sent. This is a server-side property on the request object.
Syntax
Read req.fresh in your Express.js route handler. Start with this line.
Express
req.fresh // Boolean
req.stale // Boolean — opposite of req.fresh
res.set('ETag', '"v1"')
if (req.fresh) return res.status(304).end()
Call
What it does
req.fresh // Boolean
Primary signature.
req.stale // Boolean — opposite of req.fresh
Related call form.
res.set('ETag', '"v1"')
Related call form.
if (req.fresh) return res.status(304).end()
Related call form.
Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.
Match → 304. Status becomes Not Modified and the body is dropped.
Miss → normal 200. The string body is sent as usual.
Compatibility
Runtime Support
req.fresh is an Express.js request property for HTTP cache validation. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers send conditional headers; they do not expose this property.
✓ Server · Express 4 & 5
req.fresh
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
req.freshExpress on Node.js
Bottom line: Set an ETag or Last-Modified, then use req.fresh (or res.send) to return efficient 304 responses.
Frequently Asked Questions
It is true when the client's cached copy is still valid compared with your response validators (ETag / Last-Modified). Fresh cache → you can send 304 Not Modified.
req.stale is the opposite: true when the cache is not valid and you should send the full body.
Clients send If-None-Match or If-Modified-Since. You set ETag or Last-Modified on the response. Express compares them to compute req.fresh.
Yes. After you set validators, res.send can turn a matching conditional GET into 304 and omit the body.
If the client sends Cache-Control: no-cache (a forced reload), req.fresh is false so you send a full response.