Express req.fresh Property

Beginner
⏱️ 8 min read
📚 Updated: May 2026
🎯 4 Code Examples

What you’ll learn

  • What req.fresh means in conditional HTTP requests.
  • How ETag and Last-Modified influence freshness.
  • How to return efficient 304 Not Modified responses.
  • How req.fresh compares with req.stale.

Usage syntax

javascript
req.fresh
req.stale
1

Send 304 when request is fresh

javascript
app.get('/news', function (req, res) {
  res.set('ETag', '"news-v1"');
  if (req.fresh) return res.status(304).end();
  res.json({ items: ['a', 'b', 'c'] });
});
2

Use Last-Modified with freshness checks

javascript
app.get('/article', function (req, res) {
  res.set('Last-Modified', new Date('2026-05-01').toUTCString());
  if (req.fresh) return res.status(304).end();
  res.send('Latest article content');
});

❓ FAQ

It indicates whether the client's cached representation is still fresh according to HTTP validators.
It is based on conditional request headers like If-None-Match and If-Modified-Since and your response validators.
Use req.stale, which is true when the cache is not valid and content should be sent again.
Yes. It is useful for efficient GET endpoints that support ETag or Last-Modified caching.
You can rely on Express defaults or set validators explicitly for predictable cache behavior.
Did you know?

req.fresh becomes true when the request is still valid against cache validators like ETag or Last-Modified.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

4 people found this page helpful