perf(registry): use weak ETag in express adapter - #1565
Open
ricardo-devis-agullo wants to merge 2 commits into
Open
perf(registry): use weak ETag in express adapter#1565ricardo-devis-agullo wants to merge 2 commits into
ricardo-devis-agullo wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change: default the express adapter to weak ETag (the Express default).
Why: packages/oc/src/registry/domain/http-server/express-adapter.ts explicitly set app.set('etag', 'strong'). No consumer relies on strong semantics (verified below). Weak keeps conditional-request/304 support with the W/ prefix and weak comparison, and restores the Express default. No static-file handling touched (registry has no express.static usage; static assets are served elsewhere).
No CPU saving is claimed: the
etagpackage SHA-1 hashes string/Buffer bodies in both weak and strong modes (verified against its source -- weak only adds the W/ prefix and relaxes comparison). Fully skipping ETag generation for JSON responses would be a separate behavior change and is out of scope for this PR.Consumer check (no reliance on strong ETags):
Fastify parity (not changed): packages/oc-fastify-server-adapter/src/index.ts:240 registers @fastify/etag with { weak: false, replyWith304: true } (strong), asserted in test/index.test.ts:43-72 and test/registry-node.ts:242-249. Left untouched to keep this PR minimal; a parity follow-up can flip weak:true plus those assertions if desired.
Verify headers:
Bench: not run. bench:quick is 3 scenarios x 3 repetitions x 15s per branch (5+ minutes for both branches), and any RPS/p95 delta would be noise given both etag modes hash identically -- reporting numbers would be misleading.