How do I access a page\'s HTTP response headers via JavaScript?
Related to this question, which was modified to ask about accessing two specific HTTP headers.
<
Service workers are able to access network information, which includes headers. The good part is that it works on any kind of request, not just XMLHttpRequest.
fetch the request with the respondWith function.postMessage function.Service workers are a bit complicated to understand, so I've built a small library that does all this. It is available on github: https://github.com/gmetais/sw-get-headers.