压缩多个CSS文件成一个并缓存一个小时。也可以使用相同的JavaScript代码,但替换下面的“文本/的CSS“和”文本 JavaScript的“,当然一定要包括。代替的。css的js文件。
复制代码 代码如下:
<?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" 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 "\n\n";
include('anotherfile.css');
echo "\n\n";
ob_flush();
您可能感兴趣的文章: