HTML and CSS Reference
In-Depth Information
Checking HTTP Response Headers. HTTP response headers define various char-
acteristics of the data that has been requested, providing information such as the server
type, the last date when the page was modified, the Content-type, and so forth. Java-
Script can retrieve this HTTP header information with two methods, the getAllRespon-
seHeaders() method and the getResponseHeader() method. The getAllResponseHeaders()
method returns a complete list of all the response headers as name/value pairs, each sep-
arated by a newline (see Figure 18.5). The getResponseHeader() method returns a string
containing a specific response header of the XMLHttpRequest object.
The following piece of code highlights how to get all the HTTP response headers,
whereas if you want only one header value you could use the getResponseHeader()
method as:
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readyState == 4) {
if (ajaxRequest.status == 200) {
Figure 18.6 HTTP response headers.
18.3.6 The Browser Cache Issue
Normally the browser caches banners, advertising, graphs, photos, and entire Web pages
in a folder so that you can hit the back button or click a link to a page you just visited,
and the image or page will be pulled from the cache. If you request a page with the same
URL as used before, the response is already in the cache and that response will be used
instead of requesting it again. Because the browser doesn't have to make an HTTP
Search WWH ::

Custom Search