Static:
1. Set the cache time
if(Is_file('./index.html ') && ( Time()-Filemtime('./index.html ') < 1200)) { require_once('./index.html ');}Else { //Introducing Database Link Operations require_once('./db.php '); $sql= "SELECT * from news where ' category_id ' = 1 and ' status ' = 1 limit 4"; Try{ $db= Db::getinstance ()Connect (); $result=mysql_query($sql,$db); $newsList=Array(); while($row=Mysql_fetch_assoc($result)) { $newsList[] =$row; } }Catch(Exception $e) { //TODO } Ob_start(); require_once(' template/index.php '); $s=ob_get_contents(); file_put_contents('./index.html ',$s); //Ob_clean ();}
Because it is the time of the cache setting, the previous cache cannot be purged, so when a static file is generated earlier, the cache content cannot be retrieved with the Ob_get_clean () function, which caches the cached content, but ob_get_ Contents () will get the cache and will not clear the cache. So use ob_get_contents ();
2. Add a button to select manual Refresh
3.CRONTAB-E timing, time-sharing day and month execution statement
Local Update:
Ajax get method, take the interface, write a JS, get the interface data and then format.
<script>$.ajax ({ "GET", "http://static.com/demo4/api/ajax.php", " JSON ", function(data) { alert (data.message); }}); </script>
Dynamic Web page static + local static