What is Routing?
In a web application, routing is the process of using URLs to drive the user interface (UI).
(It has a different meaning in traditional internetworking. In internetworking, the process of moving a packet of data from source to destination).)
What is server-side environment?
Files (HTML, CSS, JS, etc) are stored on the web servers (sometimes physical server racks). User requests are fulfilled by running a script on the server to generate dynamic HTML pages.
What is client-side environment?
Processing takes place on user’s computer, usually a browser. Source code is transferred from the server to the user’s computer.
How is routing done server-side?
Url routing causes whole page to refresh because GET request to server is responded by a new document, and discards old page (there’s a cache so previously visited pages are loaded faster).
Pros?
Only request data that’s needed.
SEO is great since server-side routing is the default
Cons?
Each request refreshes the entire page.
The above results in static footer and navbar for efficiency.
May take longer to render if document is large.
How is routing done client-side?
Handled internally by JS loaded, and url routing does not send a request to the server.
Pros?
Routing between views is faster (less data processed).
Smooth transitions.
Cons?
Whole website needs to be loaded, resulting in slow initial loading.
More set-up (libraries, etc) and coding needed.
SEO less optimized.
Best practices?
References:
https://medium.com/@wilbo/server-side-vs-client-side-routing-71d710e9227f
https://whatis.techtarget.com/definition/Web-server
https://www.sqa.org.uk/e-learning/ClientSide01CD/page_18.htm