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

Disable escape of response object #142

Closed Delagen closed 9 years ago

Delagen commented 9 years ago

Replace angular.toJson escape function with JSON.stringify

 // Set item
    _this.$$storage.setItem(_this.$$prefix + '.data.' + key, angular.toJson(item));

Angular only escape request object due possibility of scope variable in request in it's default transformRequest implementation, which can be disabled.

Response isn't escaped at all and cache provider MUST NOT.

This make caching function break some responses due to cleaning of dollar starting variables names so cache brokes it's content and on second request return cleaned object instead of original.

Delagen commented 9 years ago

On keys it's can be stayed at old version, changes needed only for value object. But I think it's all works as expected and removed unneeded wrapper in this case. Thanks for fast response.