webpage caching
<p>I am looking for a best solution for caching my webpages example http:/www.website.com/test.php?d=2011-11-01 which has url rewrite rule to become http:/www.website.com/testd-2011-11-01.html</p>

<p>the scripts below does not work for dynamic web page it give the same page regardless of the query.</p>

<pre><code>&lt;?php

  $cachefile = "cache/".$reqfilename.".html";


  $cachetime = 240 * 60; // 5 minutes


  // Serve from the cache if it is younger than $cachetime

  if (file_exists($cachefile) &amp;&amp; (time() - $cachetime
     &lt; filemtime($cachefile))) 
  {

     include($cachefile);


     echo "&lt;!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." 
     --&gt;";


     exit;

  }

  ob_start(); // start the output buffer?&gt;

my website content here

&lt;?php
   // open the cache file for writing
   $fp = fopen($cachefile, 'w'); 


   // save the contents of output buffer to the file
    fwrite($fp, ob_get_contents());

    // close the file

    fclose($fp); 

    // Send the output to the browser
    ob_end_flush(); ?&gt;
</code></pre>
