question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set Etag automatically for each request

See original GitHub issue

We 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:closed
  • Created 5 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
adityapatadiacommented, Jun 25, 2019

I’m not going to look at Express or Koa. I don’t know those frameworks and have never used them. I implemented this plugin by reading the RFC, as is plainly stated in the opening of the README.

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.

0reactions
stale[bot]commented, Oct 21, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found