The vagaries of web apps

By Serdar Yegulalp | 2016/07/18 08:00

One of the disadvantages of creating a web application that's meant to run on commodity hosting is that some of your choices are severely limited. Case in point: I found out today that I can't get my web host to incrementally deliver a page when using FastCGI -- it's cached completely until it's ready for output. The options I found in Apache HTTPD to control this don't seem to be enabled for people on my tier of hosting.

This is really bad news if you want to stream a report that takes a long time to generate -- like, say, the report from the export/dump-database process.

I concocted what I think is a partial workaround, but I'm still not thrilled with it:

  1. When you start the process, you open a page to a static file whose pathname and name are generated from the user's session information. (This is to prevent people from reverse-engineering the path for the report.)
  2. During the process, the results are written incrementally to the file.
  3. The client end has a script that reads from the file every second or so, and uses the Range: header in the HTTP RFC to continue reading from the last point where it left off, so it doesn't have to reload the whole file.
  4. When the end of the report is reached, the client signals that the report can be deleted from the server.

This is as horrible a kludge as I've ever come across, but it's about the only answer I can come up with that has at least some guarantee of portability.

Tags: Apache HTTP

comments powered by Disqus