PHP

JavaScript- CSS- , ( ). , , , , gz- , md5- .

:

function cache_js(){
 $arrNewJS=array();
 $strHash='';
 $strGzipContent='';
 $intLastModified=0;

//   >
 foreach ((array)$this->scripts as $file){
 if (substr($file,0,5)=='http:') continue;
 if ($file[0]=='/') $strFilename=sys_root.$file;
 else $strFilename=sys_root.'app/front/view/'.$file;
 $strHash.=$file;

//     
 $strGzipContent.=file_get_contents($strFilename);
               $intLastModified=$intLastModified<filemtime($strFilename) ?
 filemtime($strFilename) : $intLastModified;
 }
 $strGzipHash=md5($strHash);
 $strGzipFile=sys_root.'app/front/view/js/bin/'.$strGzipHash.'.gz';

// ,    gz-
 if (file_exists($strGzipFile) && $intLastModified>filemtime($strGzipFile) || !file_exists($strGzipFile)){
 if (!file_exists($strGzipFile)) touch($strGzipFile);

//     php  zlib  
 $gz = gzopen($strGzipFile,'w9');
 gzputs ($gz, $strGzipContent);
 gzclose($gz);
 }

//     
 $arrNewJS[]='js/bin/'.$strGzipHash.'.gz';
 $this->scripts=$arrNewJS
}

CSS , . YUI Compressor, ( , , , , ) .