Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XMLHTTPRequest caching problem

From: Adrian Herscu <bmf1972@-------.--->
To: NULL
Date: 7/2/2005 2:29:00 PM
Hi Neil,

Although I never used PHP, by looking at your snippet I recognize that 
this solution is not different from the previous -- both circumvent the 
caching mechanisms between the server and its clients :-(

This solution is worse than the previous one since it requires the 
installation of some server-side software (the PHP script requires a 
special scripting engine).

But I guess that I will have to live with this:
"The Mozilla XMLHttpRequest does not cache at all - you have to handle 
that. The IE implementation caches by default unless told not to by the 
server or when a request header is sent that involves caching (like 
If-Modified-Since)"
...until somebody at Microsoft will dare to fix this bug (in Mozilla it 
is already fixed).

Thanks for your time,
Adrian.



Neil Smith [MVP Digital Media] wrote:
> Yes, set the headers correctly on your server for the directory.
> 
> In PHP you'd use this (then send the XML file contents) :
> 
> header( "Expires: Sat, 1 Jan 2005 01:00:00 GMT" ); 
> header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); 
> header( "Cache-Control: no-cache, must-revalidate" ); 
> header( "Pragma: no-cache" );
> 
> There's more information about controlling this in IE (client-side)
> here :
> 
> http://jpspan.sourceforge.net/wiki/doku.php?id=javascript:xmlhttprequest:behaviour:httpheaders#conditional_get
> 
> HTH
> Cheers - Neil
> 
> On Fri, 01 Jul 2005 15:01:58 +0300, Adrian Herscu
> <bmf1972@a...> wrote:
> 
> 
>>Any suggestion about how to work around this XMLHTTPRequest caching problem?
>>
>>Adrian.
>>
>>BTW Mozilla does the opposite - it always brings the XML files without 
>>caching (although this has been fixed in developer builds).
>>
>>Adrian Herscu wrote:
>>
>>
>>>Hi Neil,
>>>
>>>Thanks for your fast reply.
>>>
>>>I know, there should be a better terminology.
>>>
>>>By "static" I meant to a file that is not generated using a 
>>>CGI/ASP/JSP/PHP/ISAPI/...
>>>
>>>But all "static" files are updated once in a time. Few examples: CSS 
>>>files are updated in order to bring a new look to the (dynamically 
>>>generated) Web pages, JS files are updated in order to bring new 
>>>behavior to the Web pages, HTML & PDF files are updated because the 
>>>documentation changed, etc., etc., etc.
>>>
>>>Then, why XML files are supposed to remain unchanged for the rest of 
>>>their life?
>>>
>>>By appending such a "random GET string to the URL" it will defeat the 
>>>caching mechanism, and files will always be retrieved. I need to load 
>>>those files only if they are newer than the cached ones. There is a 
>>>special HTTP header that does exactly that: "if-modified-since".
>>>
>>>MS-IE uses this header to bring all ("static") files which are 
>>>_hyperlinked_ from the main HTML file (i.e., scripts, stylesheets, XML, 
>>>XSLT, images, etc.) - because some mysterious reason, MS-XML decides not 
>>>to revalidate it cache.
>>>
>>>Any workaround?
>>>
>>>Thanks
>>>Adrian.
>>>
>>>Neil Smith [MVP Digital Media] wrote:
>>>
>>>
>>>>(Q : If it's static, why does it matter if it retrieves from the
>>>>cache, surely a static file *hasn't* changed, that's what the cache is
>>>>for !)
>>>>
>>>>A : As for all cached files you want to regenerate (e.g. a logging
>>>>image) append a random GET string to the URL, so for example
>>>>
>>>><script language="javascript1.2">
>>>>var randomItem=new Date();
>>>>documentHref=documentHref+'?random='+randomItem.getUTCMilliseconds();
>>>>//    Etc etc
>>>></script>
>>>>
>>>>On Thu, 23 Jun 2005 00:08:23 +0300, Adrian Herscu
>>>><bmf1972@a...> wrote:
>>>>
>>>>
>>>>
>>>>>Hi all,
>>>>>
>>>>>I am using MSXML 3.0 to synchronously load XML documents in the browser.
>>>>>
>>>>>Here is a snippet:
>>>>>
>>>>>xmlHttpRequest = new ActiveXObject( "MSXML2.XMLHTTP.3.0" );
>>>>>xmlHttpRequest.open( "GET", documentHref, false );
>>>>>xmlHttpRequest.send( null );
>>>>>
>>>>>documentHref always points to a _static_ XML file.
>>>>>
>>>>>This generates no HTTP request - the browser retrieves the file from 
>>>>>its cache.
>>>>>
>>>>>Is it possible to make it send a conditional GET?
>>>>>
>>>>>Thanks for your time,
>>>>>Adrian.
>>>>
>>>>
>>>>
> 


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent