如何在Varnish中禁用“Transfer-Encoding:chunked”编码? [英] How do I disable 'Transfer-Encoding: chunked' encoding in Varnish?

查看:218
本文介绍了如何在Varnish中禁用“Transfer-Encoding:chunked”编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Varnish 4 ,我有一套后端'使用有效的内容长度标头重新回复,并且没有转移编码标头。

Using Varnish 4, I have a set of backends that're responding with a valid Content-Length header and no Transfer-Encoding header.

在客户端第一次点击时,Varnish正在删除 Content-Length 标题并添加转移编码:chunked 到响应。 (有趣的是,有效载荷似乎没有任何块 - 它是一个连续的有效载荷)。

On the first hit from a client, rather than responding to the client with those headers, Varnish is dropping the Content-Length header and adding Transfer-Encoding: chunked to the response. (Interestingly, the payload doesn't appear to have any chunks in it - it's one contiguous payload).

这会给像Flash视频播放器这样的客户造成严重问题根据 Content-Length 标头进行分段大小,带宽等分析。他们的分析失败了,他们不能做多比特流等等。

This causes serious problems for clients like Flash video players that are trying to do segment-size, bandwidth, etc analysis based on the Content-Length header. Their analysis fails, and they can't do things like multi-bitrate streaming, etc.

我尝试过一些半明显的事情,如:

I've tried a number of semi-obvious things like:


  • beresp.do_stream = true

  • beresp.do_gzip = false

  • unset req.http.Accept-Encoding

  • beresp.do_stream = true
  • beresp.do_gzip = false
  • unset req.http.Accept-Encoding

示例后端响应:

HTTP/1.1 200 OK
Cache-Control: public, max-age=600
Content-Type: video/mp4
Date: Tue, 13 May 2014 19:44:35 GMT
Server: Apache
Content-Length: 796618
Connection: keep-alive

样本清漆响应:

HTTP/1.1 200 OK
Server: Apache
Cache-Control: public, max-age=600
Content-Type: video/mp4
Date: Tue, 13 May 2014 23:10:06 GMT
X-Varnish: 2
Age: 0
Transfer-Encoding: chunked
Accept-Ranges: bytes

后续加载对象 包括 Content-Length 标题,而不是第一次加载到缓存中。

Subsequent loads of the object do including the Content-Length header, just not the first load into cache.

VCL: https://gist.github.com/onethumb/e64a405cc579909cace1

varnishlog输出: https://gist.github.com/onethumb/e66a2bc4727a3a5340b6

varnishlog output: https://gist.github.com/onethumb/e66a2bc4727a3a5340b6

Varnish Trac: https://www.varnish-cache.org/trac/ticket/1506

Varnish Trac: https://www.varnish-cache.org/trac/ticket/1506

推荐答案

当时是, do_stream = false 将做你想要的。

For the time being, do_stream = false will do what you want.

避免后端发送unchunked的情况下的分块编码可能是对Varnish的未来改进。

Avoiding chunked encoding for the case where the backend sends unchunked is a possible future improvement to Varnish.

示例:

sub vcl_backend_response {
        if(beresp.http.Content-Type ~ "video") {
                set beresp.do_stream = false;
                set beresp.do_gzip = false;
                //set resp.http.Content-Length = beresp.http.Content-Length;
        }
        if(beresp.http.Edge-Control == "no-store") {
                set beresp.uncacheable = true;
                set beresp.ttl = 60s;
                set beresp.http.Smug-Cacheable = "No";
                return(deliver);
        }
}

这篇关于如何在Varnish中禁用“Transfer-Encoding:chunked”编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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