redux-api icon indicating copy to clipboard operation
redux-api copied to clipboard

All methods are cached

Open paradoxxxzero opened this issue 8 years ago • 7 comments

PUT, POST, DELETE methods aren't executed when cache is enabled (and a previous request has been made within the cache window)

This is really problematic, only GET methods should be cached. I think something like this should fix it:

 const cacheManager = params.method === 'GET' && getCacheManager(options.expire, meta.cache);

https://github.com/lexich/redux-api/blob/master/src/actionFn.js#L59

Otherwise the cache works fine now (#135)

paradoxxxzero avatar May 05 '17 14:05 paradoxxxzero

Yes, I think that you are right, but I don't think that fix should be so simple :)

lexich avatar May 05 '17 14:05 lexich

Well, I tried :)

On a side note I have another problem: I can't PUT 2 elements simultaneously due to this line https://github.com/lexich/redux-api/blob/master/src/actionFn.js#L132 the second gets ignored. Is there any workaround?

paradoxxxzero avatar May 05 '17 15:05 paradoxxxzero

You can't do this if you control state. But if you need put without update state (2 simultaneously request) you shoud use request method. It's simple request without redux wrappers

lexich avatar May 05 '17 15:05 lexich

Yes you're right thanks !

paradoxxxzero avatar May 05 '17 15:05 paradoxxxzero

Having the same issue. Has this been resolved? or is there a simple workaround?

ianloubser avatar Feb 27 '19 14:02 ianloubser

@ianloubser use .request method and control state manually

lexich avatar Feb 27 '19 15:02 lexich

Sorry I meant for the cached POST, PUT and DELETE methods. The original issue described here

ianloubser avatar Feb 27 '19 16:02 ianloubser