On Wednesday 29 November 2006 18:13, Thomas Hervé wrote:
> Diez B. Roggisch a écrit :
> > So - is there any chance such a thing could be made (optionally) part of
> > the Async-package?
>
> If a patch is provided, why not. Until then, you have several options:
> * define the cache control in your web server (with pragma no-cache and
> cache-control).
> * Add an argument to loadJSONdoc(): loadJSONdoc('http://toto',
> {'no-cache': new Date().getTime()})

See the patch attached. 

One turns on cache prevention via 

MochiKit.Async.PREVENT_CACHING_PARAM = 'preventCaching';

The set value is then used as parameter-name. As by your suggestion, I use the 
timestamp.

Works great for me so far. I chose the global variable way because I wanted to 
be as unobtrusive as possible - after all, if you want this, I presume you 
will want it everywhere, and hunting down all async calls that possibly need 
an additional parameter is considerably harder.

Diez


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---
Index: MochiKit/Async.js
===================================================================
--- MochiKit/Async.js	(revision 1225)
+++ MochiKit/Async.js	(working copy)
@@ -365,6 +365,14 @@
                 url += "?" + qs;
             }
         }
+	if(self.PREVENT_CACHING_PARAM) {
+	  if(url.indexOf("?") >=0) {
+	    url += "&";
+	  } else {
+	    url += "?";
+	  }
+	  url += self.PREVENT_CACHING_PARAM + "=" + new Date().getTime();
+	}
         req.open(opts.method, url, true, opts.username, opts.password);
         if (req.overrideMimeType && opts.mimeType) {
             req.overrideMimeType(opts.mimeType);

Reply via email to