Skip to content

Conversation

@jonathan-fulton
Copy link

Summary

When Cache-Control: no-store is set, the client is required to ignore any ETag header. Generating ETags for these responses wastes CPU cycles on CRC/hash computation that the client will never use.

Solution

Check the Cache-Control header for no-store directive before generating ETags. If present, skip the ETag generation entirely.

Changes

  • Modified lib/response.js to check for no-store in Cache-Control
  • Uses a regex that correctly matches no-store as a standalone directive
  • Added tests for both Cache-Control: no-store and combined directives like private, no-store, max-age=0

Performance

Eliminates unnecessary hash computation for responses that explicitly don't want caching.

Fixes #2472

When Cache-Control header contains 'no-store', skip ETag generation
since clients will ignore it anyway. This avoids unnecessary hashing
operations for responses that explicitly don't want caching.

Fixes expressjs#2472
@bjohansebas
Copy link
Member

bjohansebas commented Feb 1, 2026

Thanks for your contribution. We know you’re using AI, and that’s not really an issue, but please don’t duplicate work that already exists.

duplicated of #6994

@bjohansebas bjohansebas closed this Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to disable ETag for certain routes?

2 participants