对于 php flush - 如何禁用特定文件的 gzip? [英] For php flush - how to disable gzip for specific file?
问题描述
我有一个对 somefile.php 的 ajax 调用.我希望 php 脚本做一个简单的任务,而不是将数据发送回用户,而不是做非常耗时的任务.所以我需要在第一个简单任务之后刷新输出.它不起作用,可能是因为我启用了 gzip.
I have a ajax call to somefile.php . i want the php script to do a simple task and than send back data to the user, and only than do very time consuming tasks. so i need to flush the output after the first simple task. it doesn't work, probably because i have gzip enables.
我绝对不想在所有 vhost 中禁用 gzip,也不想在 somefile.php 所在的所有文件夹中禁用 gzip.我只想为这个特定文件禁用它.这可能吗?
I definitely don't want to disable gzip across all the vhost, and also not in all the folder where somefile.php is. i just want to disable it for this specific file. is that possible?
这是我的 apache conf 中包含的内容:
this is what i've included in my apache conf:
<FilesMatch \.php$>
SetEnv no-gzip 1
</FilesMatch>
这是我的 php 脚本:
this is my php script:
<?php
$sucesss = @apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
ob_start();
for($i=0;$i<10;$i++)
{
echo 'printing...';
ob_flush();
flush();
sleep(1);
}
?>
它不起作用.10 秒后我仍然可以看到所有输出.
it doesn't work. i still see all the output together after 10 seconds.
推荐答案
我正在寻找相同问题的解决方案.这对我有用,但不幸的是,它似乎不是一个有效的标头.
I was looking for a solutions for the same issue. This is what worked for me but unfortunately it seams NOT to be a VALID header.
<?
header("Content-Encoding: none");
?>
这篇关于对于 php flush - 如何禁用特定文件的 gzip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!