A simple cache example but it's too simple. Some _php tutorials

Source: Internet
Author: User
First create the "cache" directory, used to write file function Bz_cache ($url, $cacheName) {global $cache; global $QUERY _string;//Here you can name your own custom $fil ename = "cache/". $cacheName. ",". $QUERY _string. ". HTML "; Here you should also test the time of the file to see if it expires//(but not done here.) Oh! Do It 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}}//At the very beginning of your PHP file put the following line of code//if (Bz_cache ("Complete URL without PARAMS", "An_identifier" ) exit (); Remember, this URL is to be complete, that is, the previous must have http://. But no arguments at the back. Online there is an example: HTTP://AZERCLIC.LABYNET.ORG/DOC.PHP3//First line is//if (Bz_cache ("Http://azerclic.labynet.org/doc.php3", "Doc" ) exit (); You will see cached file in http://azerclic.labynet.org/cache///thats all///Good luck! I estimate that under the WIN32 is not a problem, under Linux also must consider the permission question, because generally does not have the Write permission.

http://www.bkjia.com/PHPjc/531724.html www.bkjia.com true http://www.bkjia.com/PHPjc/531724.html techarticle /////Create the cache directory to write the file function Bz_cache ($url, $cacheName) {global $cache; global $QUERY _string;//Here you can name your own custom $f Ilename = ca ...

  • 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.