Search code examples
httpnginxetag

Should I add ETag for all APIs


Is ok to add Etag for all APIs (GET)? Is common scenario or not? I am considering to add ETag for all apis so that can reduce the network traffic. But it will need to implement the hash computing on backend so the server's loading will increase a little bit. That's the props and cons I can think of now.

API for Types, Charts, member informcation...

BTW, I use NGINX as my webserver to serve the ASP.NET Core web API run behind Kestrel server


Solution

  • I don't think hash computing is something to worry about, especially so if you cache it somewhere.

    If you're still worried you can use a different HTTP validator, like Last-Modified header.