对于PHP冲洗 - 如何为特定文件禁用它? [英] For php flush - how to disable gzip for specific file?

查看:157
本文介绍了对于PHP冲洗 - 如何为特定文件禁用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Ajax调用somefile.php。我想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.

我绝对不希望在所有虚拟主机禁用gzip和也不在somefile.php是所有的文件夹。我只是想禁用此特定文件。这可能吗?

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脚本:

<?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冲洗 - 如何为特定文件禁用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆