Actually you could use x-mixed-replace with other content-types like text/html. I don't know if it still works with modern browser but you should be able to put the counter in an iframe.
Yep, I like this as well. I'm an 18 year old cofounder/designer hacker and sent him an email to hopefully get connected. I'm always on the lookout for young people like me that have started early. (not to bash on anyone that started late, but it's cool to meet people along my same path)
Yeah, as ceol said, that'd essentially be polling. Plus, if you can place an iframe, you can almost always place Javascript which makes something with ajax or socket.io somewhat more suitable.
But there are many places on the internet where you can only link an image, such as in sites with markdown, bbcode, or hotlinked avatars.
Wouldn't that be accomplishing the same thing— since M-JPEG keeps the connection open— except you're forcing the client to send another request when they refresh?
very cool, and apparently quite simple. but when I look at the network log with the developper tools apparently chrome doesnt register loading a new image. is it possible that it will never show up there because it doesnt finish loading?
looking at the response headers of online.png shows:
Also, it can be any image type (or file type, for that matter) besides image/jpeg. In my program, I'm sending image/png so that the rendered font is more readable.
As HTTP is stateless it's hard to tell when a user has disconnected, you can make the count more accurate by starting a session for each user then incrementing a "last_connected" timestamp by N seconds for each hit (can you tie this to each COMET update? Perhaps with JS?), then expiring any sessions that haven't been updated for a while. This is how a few popular CMS' (Drupal, Joomla) implement the "Who's Online" count.
Sounds like there would be some issues with PHP script timeouts, since you'd have to tie up a whole web server thread with a connection that doesn't close.
Darn. Yep, I can't figure out how to fix the bug causing that. I went to sleep hoping that it would in fact not be bugged and return to near-zero by the time I woke up, and now I can see that the bug is still very much there. Hmm.
M-JPEG is a concatenated stream of JPEG images, usually with some of the JPEG elements omitted.
x-mixed-replace is what he is using. It is from the early Netscape days and let you server side push new content. In this case JPEG images.
Either technique can be used to stream images depending on browser capabilities.