{"action":"created","issue":{"url":"https://api.github.com/repos/hapijs/inert/issues/29","labels_url":"https://api.github.com/repos/hapijs/inert/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/inert/issues/29/comments","events_url":"https://api.github.com/repos/hapijs/inert/issues/29/events","html_url":"https://github.com/hapijs/inert/issues/29","id":93813889,"number":29,"title":"New ETag generation method","user":{"login":"kanongil","id":753512,"avatar_url":"https://avatars.githubusercontent.com/u/753512?v=3","gravatar_id":"","url":"https://api.github.com/users/kanongil","html_url":"https://github.com/kanongil","followers_url":"https://api.github.com/users/kanongil/followers","following_url":"https://api.github.com/users/kanongil/following{/other_user}","gists_url":"https://api.github.com/users/kanongil/gists{/gist_id}","starred_url":"https://api.github.com/users/kanongil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kanongil/subscriptions","organizations_url":"https://api.github.com/users/kanongil/orgs","repos_url":"https://api.github.com/users/kanongil/repos","events_url":"https://api.github.com/users/kanongil/events{/privacy}","received_events_url":"https://api.github.com/users/kanongil/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hapijs/inert/labels/enhancement","name":"enhancement","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-08T15:08:24Z","updated_at":"2015-07-08T21:58:19Z","closed_at":null,"body":"Currently ETags are calculated based on the SHA1 hash of the file. This requires a file to be completely read before its tag can be calculated and put into the header of a request. To circumvent this, inert currently omits the ETag header until a complete file has been served to a client, caching the value for future requests.\r\n\r\nThe file hashing causes undue complexity for limited gains, and I would like to replace this with a value computed from: `modification time` + `file size`, similar to nginx & express.js.\r\n\r\nAs far as I can tell, this updated method should mainly affect cases where the same file is stored on multiple servers, served by different hapi instances behind a load balancer. Currently they are always served with the same ETag, but will require synchronization of the modification dates to achieve the same result with the new method.\r\n\r\nI'm considering to completely replace the generation method but am also considering adding it as a new `etagMethod` option, to allow consistent tag values across servers for git deployed assets, etc.\r\n\r\nAny input on this would be much appreciated."},"comment":{"url":"https://api.github.com/repos/hapijs/inert/issues/comments/119743919","html_url":"https://github.com/hapijs/inert/issues/29#issuecomment-119743919","issue_url":"https://api.github.com/repos/hapijs/inert/issues/29","id":119743919,"user":{"login":"kanongil","id":753512,"avatar_url":"https://avatars.githubusercontent.com/u/753512?v=3","gravatar_id":"","url":"https://api.github.com/users/kanongil","html_url":"https://github.com/kanongil","followers_url":"https://api.github.com/users/kanongil/followers","following_url":"https://api.github.com/users/kanongil/following{/other_user}","gists_url":"https://api.github.com/users/kanongil/gists{/gist_id}","starred_url":"https://api.github.com/users/kanongil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kanongil/subscriptions","organizations_url":"https://api.github.com/users/kanongil/orgs","repos_url":"https://api.github.com/users/kanongil/repos","events_url":"https://api.github.com/users/kanongil/events{/privacy}","received_events_url":"https://api.github.com/users/kanongil/received_events","type":"User","site_admin":false},"created_at":"2015-07-08T21:58:18Z","updated_at":"2015-07-08T21:58:18Z","body":"I thought that might be the case, though it should only be a problem for distributed deployments that don't control the modification time of the deployed static assets (like git). I am still vary on keeping it, as is, since it causes inconsistent behavior as seen in https://github.com/hapijs/hapi/issues/2628-\r\n\r\nActually, I think a better solution might be to update the current hashing logic to always add an ETag to responses at the expense of latency on uncached requests, while keeping this \"new\" method as an option for cases where you need the extra performance and hopefully understand its limits."}}