Handling “If-None-Match” header with angular resouce?

萝らか妹 提交于 2019-12-11 03:31:07

问题


I have an angular app which talks to my rails api via ng resource. In my response I set etag in my header which I get in my response headers but while making the same query again If-None-Match header is not set and in turn my caching doesn't works whereas when i make requests directly via the browser it works correctly. How can I set the received etag in my request headers with $resource


回答1:


$resource doesn't natively support etags, one way of doing it is using $cachefactory and interceptors. I did a similar thing for a project but your mileage may vary.

For a better solution look at Restangular or angular-data.



来源:https://stackoverflow.com/questions/29067097/handling-if-none-match-header-with-angular-resouce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!