Home  >  Article  >  Backend Development  >  PHP compresses multiple CSS into one css code and caches it_PHP tutorial

PHP compresses multiple CSS into one css code and caches it_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:30:041076browse

复制代码 代码如下:

/*
Compress multiple CSS files into one and cache for an hour.

Use the same code for Javascript, but replace below "text/css" with "text/javascript" and of course make sure you include .js files instead of .css ones.
*/
ob_start("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");    
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 60*60)." GMT");

include('somefile.css');
echo "nn";
include('anotherfile.css');
echo "nn";

ob_flush();

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/323290.htmlTechArticle复制代码 代码如下: ?php /* Compress multiple CSS files into one and cache for an hour. Use the same code for Javascript, but replace below "text/css" with "text/javascript"...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn