[英]Setting Content-Length Header for Magento
I'm battling some site performance issues now and one of the recommendations is to disable chunked encoding . 我现在正在解决一些网站性能问题,建议之一是禁用分块编码 。
Our site pages aren't large enough to need it and there's too much overhead. 我们的网站页面不够大,不需要它,而且开销太大。 I'm not very familiar with HTTP headers, but what I've learned is that the "
Transfer-Encoding: chunked
" header gets set automatically if you do not have a " Content-Length
" header. 我对HTTP标头不是很熟悉,但是据我了解,如果您没有“
Content-Length
”标头,则会自动设置“ Transfer-Encoding: chunked
”标头。
Does anyone know how I could go about setting the " Content-Length
" header in Magento? 有谁知道我该如何在Magento中设置“
Content-Length
”标头? It would need to work for all pages as well as for any pages that are cached (We use the Lightspeed full page caching extension). 它需要适用于所有页面以及所有缓存的页面(我们使用Lightspeed全页面缓存扩展名)。
I can't speak for the Lightspeed full page caching extension (you need to contact their support for your issue), but as magento has a single entry point via index.php
, you can hack it and wrap the output in a buffer: 我不能说Lightspeed整页缓存扩展 (您需要联系他们的支持来解决您的问题),但是由于magento通过
index.php
具有单个入口点,因此您可以对其进行破解并将输出包装在缓冲区中:
ob_start();
# ... run magento here
$buffer = ob_get_clean();
You then set the content-length header: 然后设置content-length标头:
header(sprintf("Content-Length: %s", strlen($buffer)));
Then sending out the buffer: 然后发送缓冲区:
echo $buffer;
This might not work with your caching extension or if other extensions are breaking the output buffering chain. 这可能不适用于您的缓存扩展,或者如果其他扩展破坏了输出缓冲链。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.