True static caching: (really generates an HTML page that calls the HTML directly in the next operation)
The first time (refresh the Web page) to determine if there is a cache file (can be set one time)
If there is no first time is (can be based on PDO) connection database lookup data output to a page and simultaneously cache (write) to a local. html file;
Once again (refresh the Web page) to determine if the cache file is stored
When a cache file exists, a direct lookup of the local cache (file_get_content) is read out
The following code is written in the CI framework
$time = ten ; //Set Cache page Expiration Time if (!is_file ( "obtest.html" ) | | time ()-filemtime ( "obtest.html" ); $time ) {Ob_start (); //Open buffer $arr [ Res ' ]= $this ->db->get ( ' user ' )->result_array (); $this ->load->view ( ' welcome_message ' , $arr ); //print_r ($arr); $info = ob_get_contents (); //Get the contents of the buffer and assign a value to $info $file = fopen ( ' obtest.html ' , ' W ' ); //Open file Info.txt fwrite ( $file , $info ); //write information to Info.txt fclose ( $file ); //Close file Info.txt } Else {echo "cache:" ; Echo file_get_contents ( "obtest.html" );}
Use of the fopen and Filemtime methods:
fopen() 函数打开文件或者 URL。fopen(文件名称,文件访问类型)w写入方式打开。filemtime() 函数返回文件内容上次的修改时间,里面跟文件名。
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the PHP true static cache OB system functions, including PHP, functional aspects, I hope that the PHP tutorial interested in a friend to help.