A simple cache example is too simple-some _ PHP tutorials

Source: Internet
Author: User
A simple cache example is too simple. First, create the cache directory to write the file functionBZ_cache ($ url, $ cacheName) {global $ cache; global $ QUERY_STRING; here you can name $ filenameca according to your habits // first create the "cache" directory to write the file function BZ_cache ($ url, $ cacheName) {global $ cache; global $ QUERY_STRING; // Here you can name $ filename = "cache/" according to your habits /". $ cacheName. ",". $ QUERY_STRING. ". html "; // here you should also test the file time to see if it has expired // (but this is not done here. Haha! Complete it by yourself !) If (file_exists ($ filename) {readfile ($ filename); return 1; // OK iv send the html page} else {if (! Isset ($ cache) {$ fcontents = join (, file ($ url ."? ". $ QUERY_STRING. "& cache = t"); $ fp = fopen ($ filename, "w"); fwrite ($ fp, $ fcontents); fclose ($ fp); return 0; /// iv to execute the file }}// put the following line of code at the beginning of your php file // if (BZ_cache ("complete url without params ", "AN_IDENTIFIER") exit (); // Remember, this URL must be complete, that is, there must be http ://. However, this parameter is not followed. // There is an example online: http://azerclic.labynet.org/doc.php3 // The first line is // if (BZ_cache (" http://azerclic.labynet.org/doc.php3 "," Doc ") exit (); // you will see the cached file in http://azerclic.labynet.org/cache/ // Thats all // good luck! // I guess there is no problem in WIN32. I still need to consider permission issues in LINUX, because generally there is no write permission.

The http://www.bkjia.com/PHPjc/531724.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/531724.htmlTechArticle// first creates a cache directory to write the file function BZ_cache ($ url, $ cacheName) {global $ cache; global $ QUERY_STRING; // Here you can name $ filename = ca...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.