How to use: On pages with high traffic on the website, usually the homepage, use iframe to call the above code, such as inserting
Reprint address:
http://blog.qita.in/?post=327
- Many times, we need to use the function of regularly generating html pages. Brief introduction to the principle: Compare the last modification time of files such as index.html with the current time. When the time difference exceeds a certain interval such as 2 hours, call the relevant page to generate a new page. The original source code is below.
-
- PHP version of scheduled page generation:
-
$file = dirname(__FILE__).'/index.html';
- $timex=time()-filemtime($file); //Interval time , unit second
- if($timex>7200){ //If the interval is greater than 2 hours, regenerate
- echo "";
- }
- ? >
Copy code
|