From 1b4b4c918b93cf70c78ad265a940d4edd8269db1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 27 Nov 2013 19:23:16 +0100 Subject: Add gzip compression to output --- inc/render.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'inc/render.inc.php') diff --git a/inc/render.inc.php b/inc/render.inc.php index dfe91ccb..1ab93965 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -32,6 +32,8 @@ class Render public static function output() { Header('Content-Type: text/html; charset=utf-8'); + $zip = (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false); + if ($zip) ob_start(); echo ' @@ -56,6 +58,14 @@ class Render ' ; + if ($zip) { + Header('Content-Encoding: gzip'); + ob_implicit_flush(false); + $gzip_contents = ob_get_contents(); + ob_end_clean(); + echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; + echo substr(gzcompress($gzip_contents, 5), 0, -4); + } } /** -- cgit v1.2.3-55-g7522