SaneMethod / jquery-ajax-localstorage-cache

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

default cacheKey function fails #46

Closed johnv-git closed 7 years ago

johnv-git commented 7 years ago

The default cacheKey generation fails for GET requests because the options url/data pair is mutated between the call to ajaxPrefilter and ajaxTransport.

In ajaxPrefilter():

In ajaxTransport():

So the default cacheKey of (url + type + data) yields: ajaxPrefilter => /path/to/api/methodGETp1=param1&p2=param2 ajaxTransport => /path/to/api/method?p1=param1&p2=param2GET

This cacheKey function works nicely for both GET and POST requests. return options.type + url + (options.data ? '?' + options.data : '');

SaneMethod commented 7 years ago

@johnv-git This is resolved as of 42c87b7. If you're still seeing this using an up-to-date version of the plugin, please open a new issue, and link to a test case where the issue can be seen.

johnv-git commented 7 years ago

Sorry about that, I hadn't noticed you'd chosen to store the generated key value in the options object!