Cache PHP Output
<p>I have a file called api.php which is loaded using parameters, for example:</p>

<p>api.php?name=NAME&amp;format=xml</p>

<p>which would return a xml page with some data, or</p>

<p>api.php?name=NAME&amp;format=JSON would return the same data in json format.</p>

<p>The xml page is generated using this:</p>

<pre><code>function generate_valid_xml_from_array($array, $node_block='xboxapi', $node_name='game') {
    $xml = '&lt;?xml version="1.0" encoding="UTF-8" ?&gt;' . "\n";

    $xml .= '&lt;' . $node_block . '&gt;' . "\n";
    $xml .= generate_xml_from_array($array, $node_name);
    $xml .= '&lt;/' . $node_block . '&gt;' . "\n";

    return $xml;
}
$xml = generate_valid_xml_from_array($array);
header('Content-type: text/xml');
print $xml;
</code></pre>

<p>and the json is returned using this:</p>

<pre><code>header('Content-type: application/json');
echo json_encode($data);
</code></pre>

<p>How would i set the returned data to be cached for 1 hour, and then updated hourly on request?</p>

<p>I have been scratching my head with this one for a while now</p>
