use*_*255 3 post caching request varnish docker
我使用清漆与码头工人 - 见百万12 /清漆
GET请求工作得很好!
但我不知道我必须在设置中设置缓存POST请求.
在谷歌我发现很多帖子(从2010年或2011年),它说POST请求不能用清漆缓存 - 这句话是否仍然正确?
或者是否有另一种缓存POST请求的方法?
这里我的varnish.vcl设置:
vcl 4.0;
backend default {
...
}
# Respond to incoming requests.
sub vcl_recv {
unset req.http.Cookie;
}
# Set a header to track a cache HIT/MISS.
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Varnish-Cache = "HIT";
}
else {
set resp.http.X-Varnish-Cache = "MISS";
}
}
# Not cache 400 - 500 status requests
sub vcl_backend_response {
if (beresp.status >= 400 && beresp.status <= 600) {
set beresp.ttl = 0s;
}
}
Run Code Online (Sandbox Code Playgroud)
感谢帮助 !
有一个Varnish模块和缓存POST请求的教程.这增加了将帖子主体添加到散列键并传递POST请求的功能.
VMOD可用于Varnish 4版本,包括以下功能:
Run Code Online (Sandbox Code Playgroud)buffer_req_body(BYTES size): buffers the request body if it is smaller than size. This function is a “better” (bug-free**) copy of std.CacheReqBody(), so please use this one instead of the one provided by the libvmod-std. Please note that retrieving req.body makes it possible to retry pass operations(POST, PUT). len_req_body(): returns the request body length. rematch_req_body(STRING re): regular expression match on request body. hash_req_body(): adds body bytes to the input hash key.
https://info.varnish-software.com/blog/caching-post-requests-with-varnish https://github.com/aondio/libvmod-bodyaccess
请注意,在此VMOD的4.1分支中,使用内置std.cache_req_body()而不是buffer_req_body(),但Varnish 4.1中的常规错误会破坏4.1分支. https://github.com/varnishcache/varnish-cache/issues/1927
| 归档时间: |
|
| 查看次数: |
4254 次 |
| 最近记录: |