added serve and removed cache for non bundle requests

This commit is contained in:
arzynik 2014-04-16 13:22:38 -07:00
parent d1c0f295ef
commit 155a1b56e1
2 changed files with 20 additions and 12 deletions

View File

@ -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);
}
}

View File

@ -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;
}
}