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.
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:
Do like! 😆