Set Etag automatically for each request
See original GitHub issueWe can provide etag
parameter in initial config which is by default set to true
. The behaviour will be to automatically set etag
header on all successful requests. In fact current implementation is not standards compliant. If I do reply.etag()
, it always generates new etag even for same payload. Ideally it should generate same for same payload.
Something like this should be good.
let etag = crypto
.createHash('sha1')
.update(payload)
.digest('base64')
.substring(0, 27);
reply.etag(etag);
Issue Analytics
- State:
- Created 5 years ago
- Comments:20 (11 by maintainers)
Top Results From Across the Web
ETag - HTTP - MDN Web Docs
The ETag (or entity tag) HTTP response header is an identifier for a specific version of a resource. It lets caches be more...
Read more >Configuring ETags (Advanced ) - Packt Subscription
Apache server automatically configures the ETag values. If all the files are going to be served from the same server, ETAG is important,...
Read more >ETags for REST with Spring - Baeldung
An ETag (entity tag) is an HTTP response header returned by an HTTP/1.1 compliant web server used to determine change in content at...
Read more >Using ETag Headers with Cloudflare
Learn how Cloudflare interacts with Entity Tag (ETag) headers set by your origin web server to ensure your resource versions cached in...
Read more >ETag and HTTP Caching - Code On Time
The engine produces the response data, calculates its hash value, and compares the new ETag with the If-None-Match value in the request header....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nowhere in RFC it is stated that response should be cached for
3600000 ms
. It was arbitrary number chosen. Basically as @StarpTech says, the cache should be removed and pure content based ETag should be implemented.I also disagree with creating fork. This is not a third party plugin but a fastify organisation official plugin. If this remains broken like this, less tech savvy users will keep using this plugin and get wrong behaviour than expected.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.