summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/css.php28
-rw-r--r--lib/exe/js.php28
2 files changed, 52 insertions, 4 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index 5d8f7058a..90f0109ef 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -92,7 +92,20 @@ function css_out(){
if(css_cacheok($cache,array_keys($files),$tplinc)){
http_conditionalRequest(filemtime($cache));
if($conf['allowdebug']) header("X-CacheUsed: $cache");
- readfile($cache);
+
+ // finally send output
+ if (http_accepts_gzip() && http_gzip_valid($cache)) {
+ header('Vary: Accept-Encoding');
+ header('Content-Encoding: gzip');
+ if (!http_sendfile($cache.'.gz')) readfile($cache.".gz");
+# } else if (http_accepts_deflate()) {
+# header('Vary: Accept-Encoding');
+# header('Content-Encoding: deflate');
+# readfile($cache.".zip");
+ } else {
+ if (!http_sendfile($cache)) readfile($cache);
+ }
+
return;
} else {
http_conditionalRequest(time());
@@ -124,9 +137,20 @@ function css_out(){
// save cache file
io_saveFile($cache,$css);
+ copy($cache,"compress.zlib://$cache.gz");
// finally send output
- print $css;
+ if (http_accepts_gzip()) {
+ header('Vary: Accept-Encoding');
+ header('Content-Encoding: gzip');
+ print gzencode($css,9,FORCE_GZIP);
+# } else if (http_accepts_deflate()) {
+# header('Vary: Accept-Encoding');
+# header('Content-Encoding: deflate');
+# print gzencode($css,9,FORCE_DEFLATE);
+ } else {
+ print $css;
+ }
}
/**
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 8101ecd50..1caa22b8d 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -64,7 +64,20 @@ function js_out(){
if(js_cacheok($cache,array_merge($files,$plugins))){
http_conditionalRequest(filemtime($cache));
if($conf['allowdebug']) header("X-CacheUsed: $cache");
- readfile($cache);
+
+ // finally send output
+ if (http_accepts_gzip() && http_gzip_valid($cache)) {
+ header('Vary: Accept-Encoding');
+ header('Content-Encoding: gzip');
+ if (!http_sendfile($cache.'.gz')) readfile($cache.".gz");
+# } else if (http_accepts_deflate()) {
+# header('Vary: Accept-Encoding');
+# header('Content-Encoding: deflate');
+# readfile($cache.".zip");
+ } else {
+ if (!http_sendfile($cache)) readfile($cache);
+ }
+
return;
} else {
http_conditionalRequest(time());
@@ -147,9 +160,20 @@ function js_out(){
// save cache file
io_saveFile($cache,$js);
+ copy($cache,"compress.zlib://$cache.gz");
// finally send output
- print $js;
+ if (http_accepts_gzip()) {
+ header('Vary: Accept-Encoding');
+ header('Content-Encoding: gzip');
+ print gzencode($js,9,FORCE_GZIP);
+# } else if (http_accepts_deflate()) {
+# header('Vary: Accept-Encoding');
+# header('Content-Encoding: deflate');
+# print gzencode($js,9,FORCE_DEFLATE);
+ } else {
+ print $js;
+ }
}
/**