PDA

View Full Version : ajaxcontent caching



itKiwi
03-17-2006, 10:57 PM
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
Experimenting with the above script, I find that changes I make to the external file I am loading into my page, are not being seen. It seems that the function is “remembering” not only my CSS file, but also the external page. My javascript ability is not so good, so I am asking if my external files are also being “remembered”, similarly to that noted in the extract below.

“Also, this function (loadobjs) will remember when a CSS or JS file has already been loaded and applied to the page, and won't load the same file again even if the link that invokes it is clicked on multiple times. This is for sake of efficiency.”

I also have some corrections to make with my CSS, which becomes very time consuming, because of this caching. What's the best way to temporarily disable it ?

Thanks
Alan

Twey
03-17-2006, 11:56 PM
Configure your server to not cache the page(s) in question. However, enable it again once you're done testing; caching is useful and shouldn't be disabled.

ddadmin
03-18-2006, 12:11 AM
See this thread for a solution: http://www.dynamicdrive.com/forums/showthread.php?t=8172

BTW, I think I'll just go ahead and add anti caching to the script right now, since it seems to be what people want.

itKiwi
03-18-2006, 10:09 AM
Works a treat !! Thanks. Great support.

I guess in a working environment, the script could check the timestamp of the external file, and download it again only if it is newer than the cached file, or would this be too inefficient ?

Alan

Twey
03-18-2006, 01:37 PM
I guess in a working environment, the script could check the timestamp of the external file, and download it again only if it is newer than the cached file, or would this be too inefficient ?That's what the original script does.

ddadmin: I think this ought to be a variable.
Also, check for data transferred via the GET URI, because this could mess up operation otherwise:

page_request.open('GET', url + (url.indexOf('?') == -1) ? '?' : '&') + 'bustcache=' + (new Date()).getTime(), true)

ddadmin
03-18-2006, 05:49 PM
Good point Twey. I've gone ahead and added bust caching as a variable:


if (bustcachevar) //if bust caching of external page
var bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)