hapi js and etags
This will be a quick post on etags, and the entity response toolkit method in hapi 17.x. This might be the first of a few posts on hapi, and web cache, but there is all ready some great content out there on the subject with the official hapi docs, which also links to a resource at developers.google.com when it comes to etags and more. Still I thought I would work out some of my own examples when it comes to this. Etags are a way to go about taging a response with a unique value that can be used as a way for a browser to know if it still has an up to date version of the content or not, and thus can still continue to use the cached resource rather than downloading the resource yet again.
1 - Basic etag example in hapi 17.x
So an etag is a way of setting a token for a request for a resource and it is a way of letting the browser know if the resource has changed or not. It can then be a hash of the state of the content itself, or some other string value of sorts that is updated not and then whenever a newer version of the content is available.
|
|
2 - updating an etag
When an etag is updated the browser will download the new content. So an etag is a great way of tagging content to help inform the browser as to the state of the content in terms of when it changed last. So it can potential be used to help reduce the amount of bandwidth used transmitting content out to clients. It is after all kind of silly for clients to keep re downloading content that has not changed after all.
|
|
3 - Conclusion
That is all for now when it comes to etags in hapi js. I will not be writing new content for hapi for a while until maybe I have some actual project of some kind that I am working on, at which point I will likely update the quality of my content on hapi.