Thorsten Schöning Thorsten Schöning - 1 year ago 115
Apache Configuration Question

How to forcefully flush HTTP headers in Apache httpd?

I need to periodically generate HTTP headers for clients and those headers need to be flushed to the client directly after one header is created. I can't wait for a body or anything else, I create a header and I want that Apache httpd sends it to the client.

I've already tried using autoflush, manual flush, large header data around 8k of data, disabled deflate modules and whatever could stand in may way, but httpd seems to ignore my wished until all headers are created and only afterwards flushes them. Depending on how fast I generate headers, the httpd process even increases memory to some hundreds of megabytes, so seems to buffer all headers.

Is there any way to get httpd to flush individual headers or is it impossible?

Answer Source

The answer is using NPH-scripts, which by default bypass the buffer of the web server. One needs to name the script nph-* and normally a web server should stop buffering headers and send them directly as they are printed and how they are. This works in my case, though using Apache httpd one needs to be careful:

Apache2 sends two HTTP headers with a mapped "nph-" CGI

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download