This project has moved. For the latest updates, please go here.
1

Closed

Caching bug if making same call to different webURLs

description

Hi Marc,

I'm working on a cascading autocomplete solution where the user enters a site URL in one input and then types a list/library name in a second input. I'm using the URL from the first input as the webURL option to call "GetListCollection" and provide the results as a data source for the autocomplete feature.

I turned on caching to avoid making an AJAX request for every keystroke (HUGE performance increase, BTW), but I noticed a bug:
  1. User enters URL in first input
  2. User enters list name in second input (works as expected)
  3. User changes URL in first input
  4. User enters list name in second input, but the autocomplete data source is still using the first URL's cached results
The caching solution does not take into account which webURL is used. I patched the bug by including the ajaxURL variable in the key for the cache on lines 1207 and 1216 in 2013.01. I tested the patch with my solution and with SPCascadeDropdowns and everything worked as expected.
// Check to see if we've already cached the results
        var cachedPromise;
        if(opt.cacheXML) {
            cachedPromise = promisesCache[msg + ajaxURL];
        }

        // If we don't have a completefunc, then we won't attempt to call it
        var thisHasCompletefunc = $.isFunction(opt.completefunc);

        if(typeof cachedPromise === "undefined") {
        
            // Finally, make the Ajax call
            promisesCache[msg + ajaxURL] = $.ajax({
Closed Dec 28, 2013 at 6:49 PM by sympmarc
Released in 2013.02

comments

sympmarc wrote Oct 5, 2013 at 5:26 PM

Fixed in 2013.02ALPHA3. I used
promisesCache[ajaxURL + msg]
just because I'm an ornery cuss. I though it would be easier to see the contents.

joshmccarty wrote Oct 5, 2013 at 7:39 PM

Works for me!

sympmarc wrote Oct 5, 2013 at 10:52 PM

If it works on your machine...

;-)