处理"如果 - 无 - 匹配"具有角头种源? [英] Handling "If-None-Match" header with angular resouce?

查看:183
本文介绍了处理"如果 - 无 - 匹配"具有角头种源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个角度应用程序,它通过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.

对于一个更好的解决方案看 Restangular 角数据

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

这篇关于处理"如果 - 无 - 匹配"具有角头种源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆