XMLHttpRequest caching problem
bmf1972 <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
Hi all,
I am using the XMLHttpRequest object to load static XML files.
My problem is, that XMLHttpRequest generates unconditional GET requests
(specifying Pragma: no-cache and Cache-Control: no-cache).
Found an earlier post in this group with no answer (appended below).
Please help, and thanks for your time,
Adrian.
Jeremy Hartley wrote:
> 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