summaryrefslogtreecommitdiffstats
path: root/lib/minimizer.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-06-15 12:07:31 +0200
committerBart Visscher <bartv@thisnet.nl>2012-06-18 11:11:46 +0200
commit617de811f786dd9282ad52c062a58072027f5637 (patch)
tree0cd1e80ae587a7273380e63ff4cfc121445b4a73 /lib/minimizer.php
parent91f69858e49c3981d31eeee428c7bf3cd5e142fe (diff)
downloadnextcloud-server-617de811f786dd9282ad52c062a58072027f5637.tar.gz
nextcloud-server-617de811f786dd9282ad52c062a58072027f5637.zip
Cache the minimized output also on the server
Diffstat (limited to 'lib/minimizer.php')
-rw-r--r--lib/minimizer.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/minimizer.php b/lib/minimizer.php
index 9f9ef086c4a..428fa477f77 100644
--- a/lib/minimizer.php
+++ b/lib/minimizer.php
@@ -26,14 +26,30 @@ abstract class OC_Minimizer
abstract public function minimizeFiles($files);
- public function output($files) {
+ public function output($files, $cache_key) {
header('Content-Type: '.$this->contentType);
OC_Response::enableCaching();
$last_modified = $this->getLastModified($files);
OC_Response::setLastModifiedHeader($last_modified);
- $out = $this->minimizeFiles($files);
- OC_Response::setETagHeader(md5($out));
+ $gzout = false;
+ $cache = new OC_Cache_FileGlobal();
+ if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)){
+ $gzout = $cache->get($cache_key.'.gz');
+ OC_Response::setETagHeader(md5($gzout));
+ }
+
+ if (!$gzout) {
+ $out = $this->minimizeFiles($files);
+ $gzout = gzencode($out);
+ $cache->set($cache_key.'.gz', $gzout);
+ }
+ if ($encoding = OC_Request::acceptGZip()) {
+ header('Content-Encoding: '.$encoding);
+ $out = $gzout;
+ } else {
+ $out = gzdecode($gzout);
+ }
header('Content-Length: '.strlen($out));
echo $out;
}