Compress Web Output using gzip in PHP

0
Your rating: None

For sending compressed content to browsers that support automatic decompression just add the following setting to your php.ini file:

zlib.output_compression=1

Browsers just tell the server that it can accept compressed responses with the Accept-Encoding header. If a browser sends Accept-Encoding: gzip or Accept-Encoding:deflate, and your PHP is built with the zlib extension, the zlib.output_compression
configuration directive then inform PHP to compress the output with the appropriate algorithm before sending it back to the browser. The browser uncompresses the data before displaying it.

You can adjust the compression level with the zlib.output_compression_level configuration directive:

; minimal compression
zlib.output_compression_level=1
; maximal compression
zlib.output_compression_level=9

Note: for higher compression levels, less data will be sent from the server to the browser, but more server CPU time will be used to compress the data.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

SEO Architect,SEO Specialist reflect my values.

By enduring black hat methods the SEO industry is setting itself up for washout and sleepwalking into oblivion.

Jobs in India