Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Matthew Carter Newsgroups: comp.lang.php Subject: Re: response for server every second Date: Thu, 11 Jun 2015 13:45:44 -0400 Organization: Ahungry (http://ahungry.com) Lines: 38 Message-ID: <871thijfzr.fsf@ahungry.com> References: <94be00e7-99d7-4d84-97a5-538535a0317d@googlegroups.com> <55784c9c$0$2956$e4fe514c@news2.news.xs4all.nl> <265d8474-cafc-4ca2-9f87-3d3502f92a29@googlegroups.com> <55795e6b$0$2931$e4fe514c@news2.news.xs4all.nl> <6f1bbfe0-6d62-4f2b-bcc1-1131aaf8b50f@googlegroups.com> <5579811c$0$2883$e4fe514c@news2.news.xs4all.nl> <5ddabf76-954e-4494-a1b3-698397d29cdf@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="5d6f737c8409ac3985f7ed62db365e59"; logging-data="4738"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19A3Cy03vmgdn5CTMMpCh30" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:X3Ll9WxfP7bLdm/cL8zxXv5rWp0= sha1:Pv09wrxpcPoaGJgD8b2UB7g/18Q= Xref: csiph.com comp.lang.php:15459 apoorv.kanungo@gmail.com writes: > Thanks for valuable output and I think I will only need one query for > all the user that will carry their id with them. > > I am keeping nodejs as an absolute last option because I am not very > familiar with it and I have a shared hosting which won't support > nodejs. > > Can I use html local storage I assume that will be faster and later I > will store that in the database. Your options are HTTP requests or sockets. If your requirement is 1s on the dot, you can't do it with HTTP requests, as there is no guarantee a web server will respond within 1 second of a request firing off. A socket is much faster, as it's a persistent connection which can receive events (there is still no 100% guarantee of a reply every 1 second, but you'll have more success adhering to this with sockets than HTTP requests - less overhead and not polling or request/response based). You could do with fine with javascript and HTTP if, instead of a firm 1s requirement, you just make chained requests/local updates (think - instead of using a setInterval javascript call to poll the server on a 1000ms timeout, recursively call your javascript polling function as part of the success condition). Maybe that would look (to the user) like an update at the 1s mark, 3s mark, 8s mark etc. That's going to be the best you'll get with shared hosting imho. -- Matthew Carter (m@ahungry.com) http://ahungry.com