首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HttpResponseCache 'PUT‘请求方法未缓存

HttpResponseCache 'PUT‘请求方法未缓存
EN

Stack Overflow用户
提问于 2014-02-28 18:35:37
回答 2查看 150关注 0票数 0

我为服务器请求使用HttpUrlConnection,为PUT请求使用HttpResponseCache 缓存response.But响应没有缓存,有人知道原因吗?缓存只用于POST和GET方法吗?

EN

回答 2

Stack Overflow用户

发布于 2014-02-28 18:40:29

某些HTTP方法必须使缓存使实体无效。这可以是Request-URI引用的实体,也可以是Location或Content-Location标头(如果存在)。这些方法包括:

  • PUT
  • DELETE
  • POST

(http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html)

票数 0
EN

Stack Overflow用户

发布于 2015-06-30 17:37:40

来自HttpResponseCache源代码的注释表明未实现对非GET的缓存:

https://android.googlesource.com/platform/libcore/+/cff1616012dc0d56c2da9af2b9b1183e76c7e044/luni/src/main/java/libcore/net/http/HttpResponseCache.java

代码语言:javascript
复制
    /*
     * Don't cache non-GET responses. We're technically allowed to cache
     * HEAD requests and some POST requests, but the complexity of doing
     * so is high and the benefit is low.
     */
   return null;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22092637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档