#native_company# #native_desc#
#native_cta#

Storing Data in the Client

By PHP Builder Staff
on July 30, 2000

PHP & JavaScript World Domination Series: Storing data in the client.

One of the things that all programmers love is to write a program which
writes another program. On the web we have two different programming
environments: the client (browser) and the server. Due to the HTTP
protocol definition we can write a program on the server which writes
another program to be executed on the client. Let’s pick PHP (of course)
for the server and JavaScript for the client. We’ll show you in this
article how you can use this scheme to store data in the client and
then minimize the data transfered between the server and the browser for
interactive applications like a chat room, a news system or whatever
you want.

Ingredients:

  • PHP4
  • JavaScript
  • Frames

The Idea:

We have been trying to develop an HTTP chat room in PHP for a while.
HTTP is not a good protocol for chatting but it is firewall/proxy immune,
can use the potential of PHP and there’s no need for Java Applets.
We have had two main problems with the chat room: first since IE doesn’t
support the PUSH method, we needed to make it a “pull” application,
(the client refreshes itself) which is unnatural for a chat application.
We decided to make the client refresh time variable, the server will
generate the refresh time as a function of the number of messages
received in the server in the last x minutes. The second problem was
deeper: since the idea is to refresh the client we would need the
server to send all the messages each time, we observed that this
implied heavy transfers and our benchmarks in a simulated simplified
chat room model showed that this was the main cause of delays in
the chat. This article deals with that second and deeper problem.

1
|
2
|
3
|
4
|
5