在生产环境中我应该打开还是关闭output_buffering?
我即将启动一个网站,我将检查 php.ini 来准备生产环境的所有设置。
我正在争论是否将output_buffering保留为开、关,或者将其设置为缓冲区限制(如4096)。打开或关闭output_buffer有什么优点或缺点吗?我读到关闭缓冲区会给你带来一些额外的性能,但是在做出决定之前我应该知道什么?
为什么要关闭它?
为什么要保留它?
为什么要保留缓冲区限制?
I'm about to launch a website and I'm going over my php.ini to prepare all the settings for a production environment.
I'm debating whether to leave output_buffering On, Off, or set it to a buffer limit (like 4096). Is there any pro's or con's to having the output_buffer turned On or Off? I've read that turning the buffer Off will give you some extra performance, but is there anything I should know before making my decision?
Why leave it off?
Why leave it on?
Why leave it on with a buffer limit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
输出缓冲最常见的用法实际上是允许您的脚本通过打印/回显等方式开始“写入”页面内容。但仍然允许稍后在脚本中调用 header() 来正常工作(因为标头只能在任何实际页面内容之前发送)。如果您的脚本使用这样的功能,那么您需要保留输出缓冲,以便您的脚本能够在所有 header() 调用正常运行的情况下继续运行。 (否则您将收到精彩的“header():警告,无法修改标头信息,标头已发送”消息。)
The most common usage of output buffering is actually to allow your scripts to begin "writing" page content via print/echo/etc. yet still allow header() calls later in the script to work properly (since headers can only be sent before any actual page content is). If your scripts make use of such, then you'll need to leave output buffering on in order for your scripts to continue functioning with all header() calls behaving properly. (Otherwise you'll get the wonderful "header(): Warning, could not modify header information, headers already sent" message.)