更新时间:2023-12-05 21:41:22
EDITED
这个问题的原始版本建议我们正在处理的HTTP头,而不是< HEAD>
在HTML文档部分。我将离开我原来的答复如下,但它实际上已经没有意义这个具体的问题。
The original version of this question suggested we were dealing with HTTP headers rather than the <head>
section on an HTML document. I will leave my original answer below, but it actually has no relevance to this specific question.
要回答这个问题pre-刷新&LT; HEAD&GT;
文档的部分 - 而这将有可能用gzip做这个组合,它可能不是没有过比Apache得到gzip的过程更加精细的控制成为可能。这是可能打破gzip压缩的流成块,可以DECOM pressed自己(的看到这个),但如果控制Apache的gzip的实施,这种程度的一种方式,然后我没有意识到这一点。
To answer the question about pre-flushing the <head>
section of a document - while it would be possible to do this in combination with gzip, it is probably not possible without more granular control over the gzip process than Apache affords. It is possible to break a gzipped stream into chunks that can be decompressed on their own (see this) but if there is a way to control Apache's gzip implementation to such a degree then I am not aware of it.
这样做可能会降低的gzip的功效,使得COM pressed规模大,而且只会是值得做的,当&LT;的
; HEAD&GT文件特别大,比如说超过10KB(这是通过阅读有关引擎盖下如何gzip的作品我来到一个有点任意值,绝对应该的不的被视为福音)。
Doing so would likely decrease the efficacy of the gzip, making the compressed size larger, and would only be worth doing when the <head>
of a document was particularly large, say, greater than 10KB (this is a somewhat arbitrary value I arrived at by reading about how gzip works under the bonnet, and should definitely not be taken as gospel).
原来的答复,与HTTP头:
Original answer, relating to the HTTP headers:
单纯从HTTP协议的角度出发,而不是正是你将如何实现这一个基于Apache服务器上,我看不到任何理由,你为什么不能preflush头,并使用gzip COM preSS身体。牢记一个事实,即标题是从不的gzip压缩(如果他们是,如何将客户知道他们过得好吗?)内容的传输编码应该当您发送头无影响
Purely from the viewpoint of the HTTP protocol, rather than exactly how you would implement it on an Apache based server, I can't see any reason why you can't preflush the headers and also use gzip to compress the body. Keeping in mind that fact that the headers are never gzipped (if they were, how would the client know they had been?), the transfer encoding of the content should have no effect on when you send the headers.
有,但两件事情要记住:
There are, however a couple of things to keep in mind:
的Content-Length:
头,而这可能是不好的做法,因为这意味着你不能使用持久连接。这会导致下一个点... 的Content-Length:
头在这个secenario。这是因为你不知道身体的大小是什么,直到你有COM pressed它,届时它已准备好发送,所以你是不是真的(从视图中的服务器的点)preflushing头,即使你不单独给他们,你开始发送体前。Content-Length:
header which while possible, is bad practice as it means you cannot use persistent connections. This leads on to the next point...Content-Length:
header in this secenario. This is because you don't know what the size of the body is until you have compressed it, by which time it is ready to send, so you are not really (from the server's point of view) preflushing the headers, even if you do send them seperately before you start to send the body.在短,是有可能做到这一点,但没有包罗万象的,是的,做或不,不这样做的答案 - 不管你会做这取决于每个请求和它的性质的响应。
In short, yes it is possible to do it, but there is no catch-all, "Yes, do it" or "No, don't do it" answer - whether you would do it depends on each request and the nature of it's response.