Write a static cache using PHP to improve the speed of the site's code, the need for friends, you can refer to the next. One, the following code requirements: 1. The system supports PHP 2. Support File_get_contents file_put_contents [can also be replaced with functions of the same function] 3. Best support Gzcompress Ii. use Method 1. Download the huncun.php file that you shared below 2. Huancun (or other) 3. Copy huncun.php to Huancun directory under 4. In the Huancun directory, create the folder cache directory 5. Load this file ("/huancun/huancun.php") in the header of the Web site common file header or both to generate static Web pages; 6. Emptying the cache Third, disadvantage 1. Using this system cannot update content in real time the cache must be emptied before it can be updated or the cache time is set to update 2. The first access is slower because there is no cache. The second time is to call the cache file, then it's fast 3. cache files for disk space, It is recommended to use a server or a larger space. Or periodically delete cache files Example
= $cachetime) {$return =file_get_contents ($cachename); $data =function_exists (gzcompress)? @gzuncompress ($return): $ Return;return unserialize ($data);} else{$return =file_get_contents ($cacheurl); Hc_writecache ($cachename, $return); return $return;} }function Hc_writecache ($name, $array) {function_exists (gzcompress)? $return =gzcompress (Serialize ($array)): $return =serialize ($array); @file_put_contents ($name, $return);}? >
|