Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
746 views
in Technique[技术] by (71.8m points)

apache - For php flush - how to disable gzip for specific file?

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.

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?

EDIT:

this is what i've included in my apache conf:

<FilesMatch .php$>
    SetEnv no-gzip 1
</FilesMatch>

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);
}
?>

it doesn't work. i still see all the output together after 10 seconds.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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");
?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...