SaneMethod / jquery-ajax-localstorage-cache

Ajax Cache backed by localStorage for jQuery
Other
379 stars 79 forks source link

Check if options.localCache is undefined before continuing #32

Closed softwarespot closed 9 years ago

softwarespot commented 9 years ago

If the user includes the function on each page, but doesn't require each ajax request to be 'cached', then more than likely they will not include localCache in the ajax options. Therefore a check for undefined should perhaps be done before anything else.

SaneMethod commented 9 years ago

This is handled by the checks against the options.localCache value, which determines what gets set in storage or value (depending on whether we're in the ajaxprefilter or the ajaxtransport function).

Since undefined logically evaluates as false (i.e. (!!undefined === false) === true), if localCache hasn't been included in the ajax options, the checks against the store or value in each function will ensure that the rest of the logic of either of these blocks won't be carried out, without the need for an additional explicit check for undefined.

softwarespot commented 9 years ago

You're correct. I am just too explicit with these things I guess.