是否可以在HTTP中缓存POST方法? [英] Is it possible to cache POST methods in HTTP?
问题描述
使用非常简单的缓存语义:如果参数相同(当然URL相同),那么它就是一个命中。那可能吗?推荐?
With very simple caching semantics: if the parameters are the same (and the URL is the same, of course), then it's a hit. Is that possible? Recommended?
推荐答案
相应的 RFC 2616 允许将响应缓存到POST消息中,如果使用适当的标题。
The corresponding RFC 2616 in section 9.5 (POST) allows the caching of the response to a POST message, if you use the appropriate headers.
对此方法的响应不可缓存,除非响应
包含适当的Cache-Control或Expires头字段。但是,
303(请参阅其他)响应可用于将用户代理指向
检索可缓存资源。
Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.
请注意,相同的RFC在第13节(在HTTP中缓存)中明确指出缓存必须在POST 请求之后使相应的实体无效。
Note that the same RFC states explicitly in section 13 (Caching in HTTP) that a cache must invalidate the corresponding entity after a POST request.
某些HTTP方法必须导致
缓存使实体无效。这是
$
Request-URI引用的实体,或者是Location或
Content-Location标头(如果存在)。
这些方法是:
Some HTTP methods MUST cause a cache to invalidate an entity. This is either the entity referred to by the Request-URI, or by the Location or Content-Location headers (if present). These methods are:
- PUT
- DELETE
- POST
我不清楚这些规范如何允许有意义的缓存。
It's not clear to me how these specifications can allow meaningful caching.
这篇关于是否可以在HTTP中缓存POST方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!