Server Side Verses Client Side

The difference between server and client side operations is a very important concept to understand when it comes to designing the architecture of a web site.

SERVER SIDE VS CLIENT SIDE

Simply put there are two distinct operations involved in displaying any web page to the visitor the first being server side operations and the second client side operations.

Server Side Operations
Server side operations are concerned with the sending of the web page data from the server to the web page visitors browser. In the case of Static Web Pages the data is simply served immediately upon request for the data from the visitors browser. If the requested page is a Dynamic Web Page then any pre processing of the page is carried out and the output is then served to the visitor.

PHP and ASP(vbscript) are server side scripting languages that are used to pre process pages and output HTML before the page is sent to the visitor. HTML is the language that the browser understands that tells it how to display the page.

Client Side Operations
Client side operations are performed on the visitors computer by the users Internet browser to display the web page as the data is received from the server.

HTML is interpreted as it is read by the browser resulting in the display of the web page within the browser. Once the page has loaded HTML cannot be reprocessed without refreshing the page.

The visitors experience on the web page can however be enhanced by means of a client side scripting language, typically Javascript used in conjunction with dynamic html and cascading style sheets, which enable interactive menu systems, hi-lighting effects, image effects, data manipulation and many other actions to be performed on the page without reloading or refreshing the page.

The relationship between server side and client side operations can be illustrated by the following example.

Suppose you wanted to display the current time on a web page. You have a number of options, you have the choice of displaying the current time according to the web server or the current time according to the visitors computer.

If you want to use the server time then server side pre processing will be required to determine the current time on the server and write it to the output in html format before the page is sent to the visitor.

To use the visitors local time, the current time on the visitors computer is used to determine the time and display it on the page. Since Javascript is running on the client side the time can be updated and displayed in real time on the page without having to reload or refresh the page.

This is not possible with server side scripting as the page needs to be re processed on the server to determine and output the new time and re send to the visitor in order for the new time to be displayed.

The server time could of course be written to the page as a Javascript variable which Javascript could then use to set a local page time variable which could then be used to keep time. However one must bear in mind that time would elapse between the server creating and writing output for the Javascript time variable and Javascript actually reading in the variable upon page loading. Also one must remember that the updating of the clock would still be performed as a client side Javascript operation.

Whether you choose to display the local time on the server side or client side or any of the standard times such as GMT, PST, EST is irrelevant as both server and client operations use the respective local time and the time zone where the server or client is located to determine the time in the aforementioned standard times.

Although primarily a client side scripting language, Javascript does offer some server side functionality however server side scripting languages such as PHP and ASP are generally far better suited to performing server side operations.

Share |
Hits:4541
©2011 VirtualShowrooms.co.za