Troubles Overcome

Notes on Web Development

Your firewall can cause CORS preflight to fail.

# #

I can’t tell you exactly why CORS preflight requests are failing in your case. There are many things you can try, but I will tell you this: if you’ve tried a few things and it won’t work, ask yourself whether you’re behind a firewall controlled by someone else. If you are, read the rest of this post.

An Ajax Alternative to PHP Output Buffering

# #

The Situation

Your user will have wait for the server to chug through a PHP script that may take 30+ seconds to finish, and you don’t want to force her to sit and wait, with no status information. The standard answer to this is to use PHP’s output buffering feature, which will allow you echo or print information piecemeal, as the script runs, rather than dumping the whole buffer once the whole script has finished.

The trouble about output buffering is that you have to disable gzip/deflate in order to get this to work, and sometimes you have to fiddle with fcgid settings and whatnot as well (depending on your server setup). Furthermore, some servers won’t allow it at all. Most importantly, browsers have different ways of dealing with the data that is returned bit-by-bit, and they’re not set in stone. So your code may break 6 months from now.