Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can Javascript view the ETAG value of a HTTP response? Can ETAG be included in a request?

Is it possible for javascript to read the ETAG value of a HTTP response?

Are there any issues in writing out an ETAG value in a HTTP Request to the server?

like image 407
makerofthings7 Avatar asked Mar 11 '12 07:03

makerofthings7


1 Answers

If it's a regularly loaded page, I think the HTTP request/response is already complete so Javascript can't access that information.

If it's an AJAX call, jQuery has the jqXHR object (documentation here), which says this.

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.

So you can call getResponseHeader() on the returned object in your success call to parse them out.

like image 158
Waynn Lue Avatar answered Nov 15 '22 00:11

Waynn Lue