Jump to content

kelsheikh

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by kelsheikh

  1. Hi I just have a question about the caching code below. Should the date function be in the filename if I want to cache the file for several days? Or if the date changes will a new file be created and used instead of the the previous cache file. Is that not even used since my if statement checks for the file modification time? Thanks for the help in understanding this. $cachefile = 'cache/cached/'.$id . date('M-d-Y').'.php'; $cachetime = 172800; // Check if the cached file is still fresh. If it is, serve it up and exit. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) { include($cachefile); exit; } ob_start(); {HTML TO CACHE} $fp = fopen($cachefile, 'w'); fwrite($fp, ob_get_contents()); fclose($fp); // finally send browser output ob_end_flush(); I basically want to cache a file for 2-3 days.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.