Closed tplaindoux closed 9 years ago
Hi @Xspirits! Sorry for the delayed response.
When you first load a $cachedResource, it checks local storage to see if there are any failed POST
, PUT
, or DELETE
requests from the last time the page was loaded -- if there are, then it'll try and make the request again. Sounds like that's what's happening in your case.
I am guessing that you're seeing an OPTIONS
request because it's trying to hit http://myAPI.com
and you're running the page from a different server, like localhost
. When you make requests like this, the browser will use Cross Origin Resource Sharing requests and headers to make sure that there's nothing fishy going on.
The quickest way to solve your issue, or at least the symptom, is to clear your local storage cache.
You can also do this from your code with:
$cachedResource.clearCache()
But keep in mind that if you run this on every page load, you'll lose the benefit of a cached write running after the page refreshes.
Feel free to reopen this issue if this doesn't solve your problem!
Hello,
A quick update if anyone meet the same issue:
Error was firing because of the timeout
parameter set and the api response taking a bit too long.
Actually, nothing's related to Angular cached resource ;) My bad, thanks for you help.
Also, for clearCache I only use it, per instance ( MyApiService.Name.clearCache() ) when I update some content, so I keep the benefits of
Well this is kind of an odd case, but I get a cycling option firing each X seconds (each 20s I'd say), which fail because... I didn't make any actual call.
This is the error :
Notice that this is an
option
call. Here is the code snippet creating the loop:Replacing
cachedResource
byressource
stops the Option cycle, that's why I think this is from angular-cached-resource.This happen on any page of the app, right on load.