Capturing PHP headers
Posted: Mon Oct 15, 2007 1:19 am
Hello,
I am writing an output caching module, and I am stuck on the issue of preserving the content type of output. When the php script runs I may call
header('Content-Type: text/javascript');
to indicate that the output is javascript.
Similarly, I might call
header('Content-Type: text/xml');
to indication that the output is xml.
It is easy to use output buffering (ob_start etc ..) to capture the actual content that is being output so that I can cache it for later. However how do I capture the headers that have been output by my script? If I must, I'll create a wrapper for the header function that saves the headers so that I can access them - but this would lose the genericity of the module.
Any tips appreciated.
Best regards
Steve Hannah
http://fas.sfu.ca/dataface
I am writing an output caching module, and I am stuck on the issue of preserving the content type of output. When the php script runs I may call
header('Content-Type: text/javascript');
to indicate that the output is javascript.
Similarly, I might call
header('Content-Type: text/xml');
to indication that the output is xml.
It is easy to use output buffering (ob_start etc ..) to capture the actual content that is being output so that I can cache it for later. However how do I capture the headers that have been output by my script? If I must, I'll create a wrapper for the header function that saves the headers so that I can access them - but this would lose the genericity of the module.
Any tips appreciated.
Best regards
Steve Hannah
http://fas.sfu.ca/dataface