I'm making a dynamic sitemap and i want it gziped before ou开发者_JAVA百科tput. How do I do that? What header should I add?
On this page two methods for sending gzipped output are outlined.
The easiest solution is to use output buffering with the ob_gzhandler:
<?php
ob_start("ob_gzhandler");
?>
The ob_gzhandler will take care of setting the correct headers. It also does not gzip the data in case the client does not support gzip encoding.
However, the ob_gzhandler requires that the Zlib library is enabled. For more details see the documentation of ob_gzhandler.
精彩评论