jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

save fake http request with slash. #155

Closed Ignasimg closed 9 years ago

Ignasimg commented 9 years ago

So I'm using the cache with $http, and for some api calls I receive many many objects.

What I wanted to do is when I call one of those calls, not only cache the answer itself, but also other possible calls that are pointless, because they'll just ask for part of the data already received.

So when I tried to

 cache.put('resource_'+escape(entry.id)+'/info', entry);

for some reason it thrown my code to execute the responseError function of the http interceptor service.

I tried removing the slash and it "works" but obviously doesn't cache the entry for the forthcoming http requests.

Thanks!

jmdobry commented 9 years ago

It comes down to caching the right data. You'll have to store your other calls in the exact same format that $http saves them. $http stores the response and all of the meta data, so you'll have to make that other stuff up.

Ignasimg commented 9 years ago

Ok but the problem is with the key name, for some reason it wont let me.cache a key which has a forward slash on it '/'

jmdobry commented 9 years ago

You can cache with any key, as long as it is a string. Can you provide the stack trace?

Ignasimg commented 9 years ago

OMG, I was trying to isolate the problem to post it here, when I noticed is not about your library, but about my code.

Totally sorry for that!