E
E
Eugene Ordinary2016-09-03 23:58:09
PHP
Eugene Ordinary, 2016-09-03 23:58:09

How to combine compression with mod_deflate and 206 Partial content in Apache?

The php script reads the file and echoes it.
The following headers are sent before echo with header.

Date: $date_gmt
Expires: $expires_gmt
Last-Modified: $date_gmt

Further, if a part of the file is requested, then it is sent
206 Partial content
Content-Range: bytes $startpos-$endpos/$fsize
Content-Length: $partsize
Accept-Ranges: bytes
Content-Type: image/svg+xml
Cache-Control: max-age=86400, must-revalidate
otherwise
200 OK
Content-Length: $fsize
Accept-Ranges: bytes
Content-Type: image/svg+xml
Cache-Control: max-age=86400, must-revalidate

Due to mod_deflate, the server adds headers
Vary: Accept-Encoding
Content-Encoding: gzip
Transfer-Encoding: chunked

This removes the Content-Length header.
Will this work correctly? How to check the response when requesting a part of a file?
How does the compression protocol work in general? Are parts of the source file compressed, after which the client unpacks them and appends them to the file, or does the client request parts of the whole archive, and then unpack the whole archive?
Maybe you should turn off compression for image/svg+xml and somehow compress the file using php before sending?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question