问题描述
我有一个角度应用程序,它通过NG资源会谈到我的Rails API。在我的答复我设置我的头ETAG我在响应头,但还是同时再犯同样的查询,如果-None-Match头没有设置,反过来我缓存不工作,而当我通过浏览器直接做出请求它工作正常。如何设置接收ETAG在我和$资源请求头
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
推荐答案
$资源
本身不支持ETag的,做它使用的一种方法 $ cachefactory
和拦截
。我做了一个类似的的一个项目,但你的里程可能会有所不同
$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.
这篇关于处理"如果 - 无 - 匹配"具有角头种源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!