title: PHP Cache specific parts of a page
body: <p>I have sections on a page that require a fair amount of resources that I would like to cache, here is an example of the page.</p>
  
  <pre><code>[=== Some Static HTML ===]
  [=== PHP Script 1 ===]
  [=== Some Static HTML ===]
  [=== PHP Script 2 ===]
  </code></pre>
  
  <p>I would like to put "PHP Script 1" into a cache file eg script1.html and include it rather than processing the whole script, and the same for Script 2.</p>
  
  <p>The problem I have is I can cache the whole page easily and it works but I would like to just cache specific parts (as above) because some things like user session data needs to be live.</p>
  
  <p>I have this class that is meant to be able to stop and start the buffer so I can pull out specific parts without breaking the rest of the page however it doesn't do what I want.
  <a href="http://pastebin.com/Ua6DDExw" rel="noreferrer">http://pastebin.com/Ua6DDExw</a></p>
  
  <p>I would like to be able to go like this below, while it would store the section in a file with a simple php inlcude rather hitting the database.</p>
  
  <pre><code>HTML Content
  
  &lt;?php
  $cache-&gt;start_buffer("cache_name");
  // PHP Script
  $cache-&gt;end_buffer("cache_name");
  ?&gt;
  
  HTML Content
  
  &lt;?php
  $cache-&gt;start_buffer("cache_name");
  // PHP Script
  $cache-&gt;end_buffer("cache_name");
  ?&gt;
  </code></pre>
  
  <p>I don't have access to memcache or anything else like that because this will be going on shared hosting.</p>
  
  <p>Any help would be great,
  Thanks</p>