in reply to Uncompress gzip from variable
As an aside, it can be quite useful to pre-compress even “ordinary” HTML (of any significant size) into gzip files so that the web server does not have to fully compress the stream each time. You can do the work ahead of time (or “on the fly, but once”) and then simply send the stream with the appropriate HTML headers. Natcherly, this qualifies as “something that has already been well-done,” such that there are a plethora of plug-ins for various platforms that will do it (more, or less) automagically for you. I didn't fully realize just how much time a web-server could be spending on the repetitious task of compressing things for transmission.