Default Caching HTTP Headers in xmlhttp
Unknown <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
I am using xmlhttp to retrieve a very large static xml file. I really
want this to be cached, so that the load time of my application is as
small as possible, however Mozilla's default HTTP Headers seem to be
made to frustrate this effort, by switching off any caching. .
See the code below and a description of its results for more details.
___________________________________________
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "huge.xml",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
alert(xmlhttp.responseText);
}
}
xmlhttp.send(null);
________________________________________________
This code will produce a GET Request with the following HTTP headers:
Cache-Control: no-cache
Pragms: no-cache
This disables any caching. I don't want this at all. I have tried to
override the values using commands like.
xmlhttp.setRequestHeader('Cache-Control', '');
xmlhttp.setRequestHeader('Pragma', '');
This has no effect at all.
Another attempt:
xmlhttp.setRequestHeader('Cache-Control', 'Hello');
xmlhttp.setRequestHeader('Pragma', 'Hello');
Produces the following HTTP Headers:
Cache-Control: Hello, no-cache
Pragms: Hello, no-cache
Which still seems to override any ability to use the caching data.
If anybody has any useful ideas or explanation for this behavior please
don't hesitate to contact me.
Kind regards,
Jeremy Hartley