PHP: Simple compression of JSON data 본문
PHP: Simple compression of JSON dataHuzy Huzy 2016.06.16 09:36
Just discovered how super simple it was to add some gz compression when for example providing JSON data from PHP.
All you need is regular output buffering with the ob_gzhandler as output callback.
$data = get_data();
// Turn on output buffering with the gzhandler
// Output as normal
The cool thing is that it actually looks at what the browser accepts before doing anything.
Before ob_gzhandler() actually sends compressed data, it determines what type of content encoding the browser will accept (“gzip”, “deflate” or none at all) and will return its output accordingly. All browsers are supported since it’s up to the browser to send the correct header saying that it accepts compressed web pages.
Tried adding it for a text field with timezone auto-completing for example, and without this handler:
With this handler:
|[PHP 7.2] mcrypt_create_iv, mcrypt_encrypt, mcrypt_decrypt is undefined function (0)||2018.08.28|
|php : Thread Safe 와 Non Thread Safe 차이점 (0)||2017.12.02|
|PHP: Simple compression of JSON data (0)||2016.06.16|
|How to call PHP function from string stored in a Variable (0)||2016.05.24|
|HTTP GET String + 등이 삭제되었을 때 (0)||2016.04.18|
|Centos 7 / Apache / PHP - mkdir(): Permission denied (0)||2016.01.20|