阿帕奇不冲洗

发布于 2024-12-12 05:12:15 字数 1137 浏览 5 评论 0原文

我在 Linux 系统上使用 Apache 2.2.1 和 PHP 5.3.8。

我需要在调用开始时刷新标头,但浏览器会一直等待,直到交付完整内容。

在命令行上,使用“php test.php”一切都按预期工作,但一旦涉及 apache 就不行了。

我尝试了一切。设置output_buffer = Off,zlib.output_compression = Off,禁用mod_deflate,SendBufferSize 512。我也在php中使用了所有不同的刷新方法。但正如我所说,在命令行上它工作得很好。

以下是响应标头:

  • Date Wed, 26 Oct 2011 16:37:07 GMT
  • Server Apache/2.2.21 (Amazon)
  • X-Powered-By PHP/5.3.8
  • Connection close
  • Transfer-Encoding chunked
  • Content-Type text/html; charset=UTF-8

我删除了每个模块,除了这些:

  • LoadModule authz_host_module module/mod_authz_host.so
  • LoadModule ldap_module module/mod_ldap.so
  • LoadModule log_config_module module/mod_log_config.so
  • LoadModule setenvif_module module/mod_setenvif.so
  • LoadModule mime_module module/mod_mime.so
  • LoadModule达夫模块模块/mod_dav.so
  • LoadModule autoindex_module 模块/mod_autoindex.so
  • LoadModule dir_module 模块/mod_dir.so
  • LoadModule alias_module 模块/mod_alias.so
  • LoadModule rewrite_module 模块/mod_rewrite.so

我希望有人可以帮助我

I use a Apache 2.2.1 with PHP 5.3.8 on a Linux system.

I need to flush the header at the beginning of the call, but the browser keeps waiting until the full content is delivered.

On the command line, using "php test.php" everything works as expected but not as soon as apache is involved.

I tried everything. Setting the output_buffer=Off, zlib.output_compression=Off, disabled mod_deflate, SendBufferSize 512. I used all the different flush methods in php also. But as i said, on the command line it works fine.

Here is the response header:

  • Date Wed, 26 Oct 2011 16:37:07 GMT
  • Server Apache/2.2.21 (Amazon)
  • X-Powered-By PHP/5.3.8
  • Connection close
  • Transfer-Encoding chunked
  • Content-Type text/html; charset=UTF-8

I removed every module, except for these:

  • LoadModule authz_host_module modules/mod_authz_host.so
  • LoadModule ldap_module modules/mod_ldap.so
  • LoadModule log_config_module modules/mod_log_config.so
  • LoadModule setenvif_module modules/mod_setenvif.so
  • LoadModule mime_module modules/mod_mime.so
  • LoadModule dav_module modules/mod_dav.so
  • LoadModule autoindex_module modules/mod_autoindex.so
  • LoadModule dir_module modules/mod_dir.so
  • LoadModule alias_module modules/mod_alias.so
  • LoadModule rewrite_module modules/mod_rewrite.so

I hope there is someone who can help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-柠檬树下少年和吉他 2024-12-19 05:12:15

很可能 Apache 刷新得很好,但浏览器决定继续缓冲(而不是启动渲染)一段时间,即使在收到初始刷新的数据后也是如此。

来自文档

flush() 可能无法覆盖您网站的缓冲方案
服务器并且它对任何客户端缓冲没有影响
浏览器。

除了特定于浏览器的黑客攻击(例如发送大量空格(几年前我不得不诉诸于此)以使浏览器“重新考虑”)之外,您实际上无能为力。

In all probability Apache is flushing just fine, but it's the browser the decides to continue buffering (and not starting render) for some time even after the initial flushed data has been received.

From the documentation:

flush() may not be able to override the buffering scheme of your web
server and it has no effect on any client-side buffering in the
browser
.

There's nothing really you can do about that apart from browser-specific hacks such as sending lots of whitespace (I had to resort to that several years ago) to make the browser "reconsider".

絕版丫頭 2024-12-19 05:12:15

您应该尝试发送带有其他 content-type 或不带有 content-type 的页面。在我们的服务器中,我们遇到了类似的问题,我们发现当 content-type 为 html 时,mod_security 会阻止刷新。

You should try send the page with another content-type or without content-type. In our server we had similar issue and we found out that mod_security blocks the flush when the content-type is html.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文