ob_start ('ob_gzhandler');
if( isset($_REQUEST['file']) ){
$fl = $_REQUEST['file'];
$extention = end(explode('.', $fl));
switch($extention){
case 'css':$contenttype = 'css';break;
case 'js':$contenttype = 'javascript';break;
default:die();break;
}
header('Content-type: text/'.$contenttype.'; charset: UTF-8');
header ('cache-control: must-revalidate');
$ost = 60 * 60;
$expr = 'expires: ' . gmdate ('D, d M Y H:i:s', time() + $ost) . ' GMT';
header ($expr);
$gzdata = file_get_contents($fl);
$gzdata = compress($gzdata);
echo $gzdata;
}
exit;
function compress($buf) {
$buf = str_replace(array("\r\n", "\r", "\n", "\t", " ", " ", " "), "", $buf);
return $buf;
} location ~* \.js$ {
rewrite_log on;
rewrite "^/(.*)$" /gzip.php?file=http://$domain/$1 last;
} 2015/05/19 13:16:22 [error] 15560#0: *5 FastCGI sent in stderr: "Unable to open primary script: /home/site.ru/html//files/rss.php (No such file or directory)" while reading response header from upstream, client: 123.123.123.123, server: _, request: "GET /files/rss.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "site.ru"