The rapid popularization of the Internet in today's society, more and more people will be in a Web application to communicate, resulting in server and database access pressure is increasing, this side needs to do some optimization, such as increased cache, level two cache, Dynamic Web page static and other high-end technology.
The author here uses the method of generating a static file:
Copy Code code as follows:
/**
* Use when generating static files @desc
* @todo Htmlcache
* @param $root string HTML file to store the path
* @param $rule string HTML file naming rules
* @param $url string to generate the Dynamic Web page address of the HTML file
* @return Boole True/false
*/
Public Function Sethtmlcache ($root, $rule, $url) {
Detect whether static files have been generated
if (file_exists $root. $rule. HTML ')) {//static file already exists
@unlink ($root. $rule. HTML ');//delete static files
Return file_put_contents ($root. $rule. HTML ', file_get_contents ($url));//Regenerate
}else{//no static file direct generation
Return file_put_contents ($root. $rule. HTML ', file_get_contents ($url));
}
}
This section method is the most common generation of static file mode, Welcome to communicate!