Asset.php
authorAlan Knowles <alan@roojs.com>
Wed, 27 Dec 2017 04:54:23 +0000 (12:54 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 27 Dec 2017 04:54:23 +0000 (12:54 +0800)
Asset.php

index 8f110c4..d0fd536 100644 (file)
--- a/Asset.php
+++ b/Asset.php
@@ -90,15 +90,30 @@ class Pman_Core_Asset extends Pman {
         
         
         header("Pragma: public");
-        header('Content-Length: '. filesize($fn));
+        
         header('Cache-Control: max-age=2592000, public');
         header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000));
         header('Last-Modified: '.gmdate('D, d M Y H:i:s \G\M\T', $last_modified_time));
         header('Etag: '. md5($fn)); 
         
-        $fh = fopen($fn,'r');
-        fpassthru($fh);
-        fclose($fh);
+         if ( $supportsGzip ) {
+            $content = gzencode( file_get_contents($fn) , 9);
+            
+            header('Content-Encoding: gzip');
+            header('Content-Length: '. strlen($content));
+            echo $content;
+            
+        } else {
+            
+            
+            $fh = fopen($fn,'r');
+            fpassthru($fh);
+            fclose($fh);
+            $content = $data;
+        }
+        
+        
+        
         exit;
         
     }