From 155a1b56e12ae151eccc7d987d431469183e14a8 Mon Sep 17 00:00:00 2001 From: arzynik Date: Wed, 16 Apr 2014 13:22:38 -0700 Subject: [PATCH] added serve and removed cache for non bundle requests --- .../default/crunchbutton/assets/scss/index.php | 14 ++------------ include/library/Crunchbutton/Scss.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/include/controllers/default/crunchbutton/assets/scss/index.php b/include/controllers/default/crunchbutton/assets/scss/index.php index 2c3e91981..027b45690 100644 --- a/include/controllers/default/crunchbutton/assets/scss/index.php +++ b/include/controllers/default/crunchbutton/assets/scss/index.php @@ -2,19 +2,9 @@ class Controller_assets_scss extends Crunchbutton_Controller_AssetBundle { public function init() { - $this->cacheServe('crunchr-file-scss'); - } - - public function getData() { - - $path = $file = c::config()->dirs->www.'assets/scss/'; + $path = c::config()->dirs->www.'assets/scss/'; $file = c::getPagePiece(2).'.scss'; - $data = Scss::compile($path.$file); - - $data = preg_replace('/\t|\n/','',$data); - $mtime = time(); - - return ['mtime' => $mtime, 'data' => $data]; + Scss::serve($path.$file); } } diff --git a/include/library/Crunchbutton/Scss.php b/include/library/Crunchbutton/Scss.php index 0bbfe3a1a..f46d95f6e 100644 --- a/include/library/Crunchbutton/Scss.php +++ b/include/library/Crunchbutton/Scss.php @@ -17,4 +17,22 @@ class Crunchbutton_Scss extends Cana_Model { return $data; } + + public static function serve($file) { + + $data = self::compile($file); + $mtime = filemtime($file); + + header('HTTP/1.1 200 OK'); + header('Date: '.date('r')); + header('Last-Modified: '.gmdate('D, d M Y H:i:s',$mtime).' GMT'); + header('Accept-Ranges: bytes'); + header('Content-Length: '.strlen($data)); + header('Content-type: text/css'); + header('Vary: Accept-Encoding'); + header('Cache-Control: max-age=290304000, public'); + + echo $data; + exit; + } } \ No newline at end of file