Client vs Server side Processing

Introduction

Things can be processed in two places: the Client, or the Server

Each method has its benefits and drawbacks

Static vs Dynamic Websites

Some websites, such as this one, do not have a proper server behind them. The client can only make GET requests, meaning the server can only serve html and other content.

This is known as a "Static" site, as nothing can change on it

However, if I were to add a login form, the site would need to have a proper server, to be able to look up your account against a database

The client would need to be able to send a POST request to the server, allowing it to process the login details.

This is a "Dynamic" site, it changes based on the server's output

A popular example of a server side language is PHP

Choosing between Client and Server

Many things need to be taken into account when deciding where data is processed.

Security, Performance and Usability are the three main deciding factors

Why use Client Side

Client side processing is usually done with JavaScript, which allows for things such as the initial data validation to take place. This would be much better for the server, as it wouldn't need to process every single request.

Other client side processings are the stylings, and manipulation of the UI, which are done on the local browser. However, this could be seen as an issue, where not all browsers support every web feature.

Why use Server Side

Server side would be seen as better in regards to security. Client side processing is prone to XSS and other malicious activities, especially if the inputs aren't validated properly because of that.

A server can do the final step in validation, keeping it's database safe

However, if the security is not good enough, they could be prone to SQL injections, possibly damaging the database


Server side rendering can be useful, as the client can recieve a page without needing to process any other aspects of it, rather than waiting for things like css and js files to load in.

Using the server too much will slow it down, especially when web traffic increases, meaning that client side is equally important