Show a real-time user count without any client-side Javascript
minipenguin.com
minipenguin.com
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.
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.
looking at the response headers of online.png shows:
Cache-Control:no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0, false
Connection:Close
Date:Sun, 29 Jul 2012 11:04:04 GMT
Expires:-1
Last-Modified:Sun, 29 Jul 2012 11:04:04 GMT
Pragma:no-cache
Transfer-Encoding:chunked
so that can't be the jpeg mentioned HTTP/1.1 200 OK
Connection: Close
Expires: -1
Last-Modified: Sun, 29 Jul 2012 17:44:35 GMT
Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0, false
Pragma: no-cache
Content-Type: multipart/x-mixed-replace; boundary=--whyhellothere
Date: Sun, 29 Jul 2012 17:44:35 GMT
Transfer-Encoding: chunked
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.
"using Backbone.js"
?
All that's required on the client is this: <img src="/online.png" />
And you're up and running.