ajax: _uniqueId and caching

3 views
Skip to first unread message

Jason S

unread,
Jan 7, 2008, 6:29:37 PM1/7/08
to Fork JavaScript
I am trying to make use of the Fork ajax lib & at the same time using
caching in a website to its advantage, since some of my requests are
just for static JSON info. What is the best way to override the
_uniqueId behavior in Fork? I'm fairly experienced w/ Javascript but
am a bit confused about side-effects and am new to the Fork object
model.

FORK.Ajax.prototype.setMethod = function() {
if (this.method === 'GET') {
// Rumor has it that at least one browser caches GET requests
// made with an XMLHttpRequest object or equivilant ActiveXObject.
// (TODO find a reference supporting this rumor.)
// To avoid using any cached response add a
// unique dummy id to the URL to make it different than all
previous
// URLs and hence insure the request has never been cached.
this.body._uniqueId = (new Date()).getTime() + "" +
FORK.Ajax.transactionId++;
}
};

Peter Michaux

unread,
Jan 8, 2008, 11:55:31 AM1/8/08
to forkjav...@googlegroups.com
Hi Jason,

I have never tried to take advantage of caching with Ajax and don't
even know what the possibilities are for the various browsers. I think
that some browsers won't cache any XMLHttpRequest responses and the
_uniqueId parameter was to ensure that all browsers behavied the same
by always making a fresh request. The best place to ask about XHR and
caching would be on comp.lang.javascript and this wouldn't even need
to involve Fork in the discussion.

I know you can take advantage of browser caching by dynamically
inserting script elements with src attributes into the page. Randy
Webb on comp.lang.javascript has done quite a bit of work on this. You
can search for his name andy script insertion in the
comp.lang.javascript archives.

http://groups.google.com/group/comp.lang.javascript/topics

Peter

Reply all
Reply to author
Forward
0 new messages