class Net_Tools_CacheControl {

/**
 * 无缓存
 */
final static public function noCache() {
    header('Cache-control: must-revalidate, max-age=0, no-cache, no-store'); // HTTP/1.1设定本页面不缓存
    header("Pragma: no-cache");                                   // HTTP/1.0 设定本页面不缓存
}

/**
 * 缓存指定时间
 * @param type $lifesec 生存时间(秒)
 */
final static public function CacheTime($lifesec = 86400, $expiretime = null) {
    $now = time();
    if (empty($expiretime)) {
        $expiretime = $now + $lifesec;
    }
    header("Expires: " . gmdate('D, d M Y H:i:s T', $expiretime));
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $now));
    header("Cache-Control: max-age=" . $lifesec);
}

}