I’m wondering how to set the max possible time limit for a php page,
set_time_limit(number);
I looked of on the long polling that Facebook use it’s 40 seconds why this number and not more ?
Is it a best practice because then the browser will cancel the request or something?
No, that’s the execution time limit, not the http connection time limit. HTTP 1.1 uses a persistent connection, meaning it won’t time out, so your limitation would actually be Apache not PHP.
Read up on Apache’s max clients to see if long polling will kill your server or not.
http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxclients
All that being said, if you really want a solid long polling setup, I’d recommend looking into NodeJS to use a non-blocking I/0.