<?php
//引入配置文件
$fillname="../cache/testhuancun.html";
//设置一个缓存时间
$time=; //判断如果缓存文件不存在的话
if(!file_exists($fillname) || filemtime($fillname)+$time<time())
{
//开启缓存
ob_start(); include("../init.inc.php");
include("../DBDA.class.php");
$db=new DBDA();
$sql="select * from nation";
$attr=$db->Query($sql);
$smarty->assign("nation",$attr);
$smarty->display("test.html");
//把内存里面的内容读出来
$nr=ob_get_contents();
//将读到的内容存放到缓存文件
file_put_contents($fillname,$nr); //清除缓存
ob_flush();
echo "##########################"; }
//如果缓存文件存在的话
else
{
include($fillname); }

随机推荐

  1. Debian 安装 vmware-tools 手记

    debian 8.5 源 deb http://ftp.de.debian.org/debian jessie main http://mirrors.163.com/.help/debian.htm ...

  2. html5 localStorage和sessionStorage

    该随便来自: http://www.cnblogs.com/yuzhongwusan/archive/2011/12/19/2293347.html html5中的Web Storage包括了两种存储 ...

  3. 利用BFS求最短路

    利用BFS求图的最短路, POJ3984 #define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<string.h& ...

  4. Box2d b2World的RayCast方法

    RayCast方法: world.RayCast(callback:Function,point1:b2Vec2,point2:b2Vec2); * callback 回调函数 * point1 射线 ...

  5. 转:HTTP协议详解(真的很经典)

    转自:http://blog.csdn.net/gueter/archive/2007/03/08/1524447.aspx Author :Jeffrey 引言 HTTP是一个属于应用层的面向对象的 ...

  6. hb_gui配置heartbeat做MariaDB的高可用

    系统平台:CentOS release 6.5 (Final) Kernel:2.6.32-431.el6.x86_64 一.启动hb_gui hb_gui & 添加资源组 添加MySQL_I ...

  7. HDU 3265 Posters ——(线段树+扫描线)

    第一次做扫描线,然后使我对线段树的理解发生了动摇= =..这个pushup写的有点神奇.代码如下: #include <stdio.h> #include <algorithm> ...

  8. spring,hibernate配置事务

    1. 新建java project 2. 引入jar 3. src下新建package:com.web.model, com.web.dao, com.web.service, bean.xml 4. ...

  9. 写入cookie后只显示一次的DIV提示框代码

    <script type="text/javascript"> function cookiesave(n, v, mins, dn, path){ if(n) { i ...

  10. ural1542 Autocompletion

    Autocompletion Time limit: 2.0 secondMemory limit: 64 MB The Japanese are infinitely in love with ma ...