From 54f9b35f71cec60880b46f5684c3a2115a0e9cda Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 26 Mar 2017 16:30:08 +0200 Subject: Allow to gzip CSS/JS files Since in production the SCSS files are compiled once and the javascript files are combined once we can just as well gzip them aggresively. This means that once they are requested and the browser supports gzip we can just serve the gzipped file saving precious bandwidth. Signed-off-by: Roeland Jago Douma --- lib/private/Template/JSCombiner.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/private/Template/JSCombiner.php') diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php index 9f92813f905..0f30fb915f7 100644 --- a/lib/private/Template/JSCombiner.php +++ b/lib/private/Template/JSCombiner.php @@ -154,9 +154,16 @@ class JSCombiner { $depFile = $folder->newFile($depFileName); } + try { + $gzipFile = $folder->getFile($fileName . '.gz'); + } catch (NotFoundException $e) { + $gzipFile = $folder->newFile($fileName . '.gz'); + } + try { $cachedfile->putContent($res); $depFile->putContent(json_encode($deps)); + $gzipFile->putContent(gzencode($res, 9)); return true; } catch (NotPermittedException $e) { return false; -- cgit v1.2.3