Some php websites are purely dynamic or mostly dynamic due to preliminary design and other reasons, and database operations are frequent, resulting in slow website access! I want to achieve static without generating static functions. because I have written a simple static program, it is very simple. at first glance, I understand that it is suitable for the basic...
Some php websites are designed in the early stage and for other reasons.
Websites are purely dynamic or mostly dynamic, and database operations are frequent.
This slows down website access! The static function is not generated.
Because I wrote a simple static program, which is easy to understand at a glance.
Suitable for basically all systems
Requirements
1. the system supports php
2. support for file_get_contents file_put_contents [can also be replaced by functions with the same function]
3. it is best to support gzcompress
Usage
1. download the huncun. php file shared below
2. create the folder huancun (or others) in the root directory of the website)
3. copy huncun. php to the huancun directory.
4. create a folder cache directory under the huancun Directory
5. load the file on a public website file header or a static webpage header.
Include ("/huancun. php ");
6. clear cache reference http://www.oschina.net/code/snippet_202258_7018
Disadvantages
1. the system cannot update the content in real time. the content must be cleared before it can be updated or updated only when the specified cache time is reached.
2. the first access was slow because there was no cache. The second access was to call the cache file, which was faster.
3. cache files occupy disk space. we recommend that you use a large server or space or regularly delete cached files.
= $ 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);}?>