复制代码 代码如下:<?php header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT‘); header(‘Last-Modified: ‘ . gmdate(‘D, d M Y H:i:s‘) . ‘GMT‘); header(‘Cache-Control: no-cache, must-revalidate‘); header(‘Pragma: no-cache‘); ?> 原文:http://www.jb51.net/article/17035.htm
内容缓存输出 PEAR cache 接下来我们开始探索更常用的缓存技术,这也是本文的重点部份。首先我们使用PEAR中的cache包。PEAR可以将内容缓存于文件,数据库或者内存中,我们以文件为例。 下面是一个没有使用缓存的PHP小程序: pear_content_cache1.php <?php echo "这是内容。<P>"; echo "当前时间是" . date('M-d-Y H:i:s A', time()) . "<BR>"; ?> 上面这个程序非常简单,现在我们为其加上缓存。 pea...
代码如下:header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); ?>
代码如下:header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); ?>
代码如下:header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); ?> http://www.bkjia.com/PHPjc/319847.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319847.htmlTechArticle 代码如下:?php header(Expires: Mon, 26 Jul 1997 05:00:00 GMT); header(Last-Modified: . gmda...
代码如下:<?php header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); ?>
页面缓存就是把页面保存到一个文件中,下次读出时直接调用文件而不查询数据库,这里我们介绍利用ob_start()来实现。 例代码如下ob_start(); //打开缓冲区 phpinfo(); //使用phpinfo函数 $info=ob_get_contents(); //得到缓冲区的内容并且赋值给$info $file=fopen(’info.txt’,’w’); //打开文件info.txt fwrite($file,$info); //写入信息到info.txt fclose($file); //关闭文件info.txt //或直接用 fil...
内容缓存输出 PEAR cache接下来我们开始探索更常用的缓存技术,这也是本文的重点部份。首先我们使用PEAR中的cache包。PEAR可以将内容缓存于文件,数据库或者内存中,我们以文件为例。下面是一个没有使用缓存的PHP小程序:pear_content_cache1.php<?php echo "这是内容。<P>"; echo "当前时间是" . date(M-d-Y H:i:s A, time()) . "<BR>"; ?>上面这个程序非常简单,现在我们为其加上缓存。pear_content_cache2.php <?php ...