summaryrefslogtreecommitdiffstats
path: root/lib/private/Template/SCSSCacher.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-03-26 16:30:08 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-03-28 21:46:23 +0200
commit54f9b35f71cec60880b46f5684c3a2115a0e9cda (patch)
treeeb5863f32396fa6bd6bacfcbc3ae54708e0345b2 /lib/private/Template/SCSSCacher.php
parente26f138fc596492da88b8a0d57749f5703e1d100 (diff)
downloadnextcloud-server-54f9b35f71cec60880b46f5684c3a2115a0e9cda.tar.gz
nextcloud-server-54f9b35f71cec60880b46f5684c3a2115a0e9cda.zip
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 <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Template/SCSSCacher.php')
-rw-r--r--lib/private/Template/SCSSCacher.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php
index c12d8771513..f3c2ec163cc 100644
--- a/lib/private/Template/SCSSCacher.php
+++ b/lib/private/Template/SCSSCacher.php
@@ -186,9 +186,18 @@ class SCSSCacher {
return false;
}
+ // Gzip file
try {
- $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir));
+ $gzipFile = $folder->getFile($fileNameCSS . '.gz');
+ } catch (NotFoundException $e) {
+ $gzipFile = $folder->newFile($fileNameCSS . '.gz');
+ }
+
+ try {
+ $data = $this->rebaseUrls($compiledScss, $webDir);
+ $cachedfile->putContent($data);
$depFile->putContent(json_encode($scss->getParsedFiles()));
+ $gzipFile->putContent(gzencode($data), 9);
$this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
return true;
} catch(NotPermittedException $e) {