问题
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