Javascript如何查看HTTP响应的ETAG值? ETAG可以包含在请求中吗?

javascript是否可以读取HTTP响应的ETAG值?

在向服务器发送HTTP请求中写出ETAG值是否有任何问题?

最佳答案 如果它是一个定期加载的页面,我认为HTTP请求/响应已经完成,因此
Javascript无法访问该信息.

如果它是一个AJAX调用,jQuery有jqXHR对象(文档here),这说明了这一点.

The jQuery XMLHttpRequest (jqXHR) object returned by $.ajax() as of jQuery 1.5 is a superset of the browser’s native XMLHttpRequest object. For example, it contains responseText and responseXML properties, as well as a getResponseHeader() method. When the transport mechanism is something other than XMLHttpRequest (for example, a script tag for a JSONP request) the jqXHR object simulates native XHR functionality where possible.

因此,您可以在成功调用中的返回对象上调用getResponseHeader()来解析它们.

点赞