V
V
vagrand2014-02-02 09:01:10
PHP
vagrand, 2014-02-02 09:01:10

Why can't I properly serve a file compressed with gzencode()?

There are a bunch of html files, completely static. I want to compress all of them using gzencode () and then directly give it to the user. And with direct feedback, the plug comes out. I prescribe the directive in .htaccess:
Header set Content-Encoding: gzip
In the browser I see that the desired header is given to me, but decoding does not occur.
And at the same time, here is the code:

$content = file_get_contents('./test.shtml');
$content = gzencode($content, 9);
header('content-encoding: gzip'); 
echo $content;

absolutely normal gives the content of the file. I checked the list of headers for both methods, everything is identical.
I encode the test file like this:
$content = file_get_contents('./test.shtml');
$content = gzencode($content, 9);
file_put_contents('./test_gz.shtml', $content);

Prompt in what there can be a business. Maybe I don't know some specifics?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vagrand, 2014-02-02
@vagrand

In general, I figured it out myself. The method I needed did not want to work only with the shtml extension, apparently some kind of muddled with SSI.

S
stepank, 2014-02-02
@stepank

apache itself can do this - httpd.apache.org/docs/2.2/mod/mod_deflate.html. why any extra movement?

M
Max, 2014-02-02
@7workers

Putting a header does not mean compressing. Google SetOutputFilter DEFLATE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question