Android 如何在截击中使用etag
我在任何地方都找不到这个问题的直接答案,所以是时候问一下了: 截击是否负责发送GET请求中的ETag 在网上研究之后,我模糊地认为是这样,但我不确定。我有一个使用etag的API。在我的代码中,我已经解释了缓存响应:Android 如何在截击中使用etag,android,android-volley,etag,Android,Android Volley,Etag,我在任何地方都找不到这个问题的直接答案,所以是时候问一下了: 截击是否负责发送GET请求中的ETag 在网上研究之后,我模糊地认为是这样,但我不确定。我有一个使用etag的API。在我的代码中,我已经解释了缓存响应: String url = Uri.parse(Statics.baseURL + "/users/" + Statics.user.getUser_id() + "/items").buildUpon() .appendQueryParameter("tok
String url = Uri.parse(Statics.baseURL + "/users/" + Statics.user.getUser_id() + "/items").buildUpon()
.appendQueryParameter("token",Statics.token)
.build().toString();
// Check to see if the response got cached
if(requestQueue.getCache().get(url)!=null){
//response exists
String cachedResponse = new String(requestQueue.getCache().get(url).data);
processItems(cachedResponse);
}
Request request = new JsonRequest(
Request.Method.GET,
url,
null,
null,
new ErrorListener(context)){
@Override
protected Response parseNetworkResponse(NetworkResponse response) {
// Only process the items if the response is modified
if(!response.notModified)
processItems(new String(response.data));
return null;
}
};
requestQueue.add(request);
如果数据被修改,我只想处理来自API的数据,但我总是得到response code=200
和notModified=false
返回
我没有手动设置
(如果没有匹配的话)
标题,因为我希望截击能帮我跟踪它。这是正确的吗?参见问题@njzk2我确实已经看到了那个问题。我在问凌空是否会以某种方式为我发送和处理ETAG?该问题的答案是1)非截击2)手动发送If None匹配标题引用问题:我正在通过Fidler观看通信,我可以看到截击[…]使用If None Match+etag字符串发送新请求
。我建议您使用代理或在服务器端检查请求的内容。此外,volley还负责缓存。好的。你知道如何让它保持跟踪吗?如果我发送etag,我正确地收到了304,但是,截击没有发送它。