Web applications and websites play a major role in modern business and consumer apps, yet very few people understand how they actually work
Content
- Web Servers
- HTTP
- HTML
- JavaScript
- PHP
- Conclusion
Web Servers
Before I explain what happens when you visit a webpage, it is important that we talk about web servers first. Web Servers are software and hardware applications that ensure the delivery of a website’s content to a user using Hypertext Transfer Protocol (HTTP) and other protocols such as File Transfer Protocol (FTP). Everytime you type a website into the address bar, the web browser sends a request to the web server, where it will send you the contents of the requested file or an error message if it was not found. Some examples of web server uses are:
- sending and receiving emails (using SMTP)
- downloading requests for FTP files (file transfer and storage)
- building and publishing webpages
There is a lot more to learn about web servers and the series of steps it takes for them to send a response to the web server, so if you are looking to learn more about web servers, make sure to read this blog.
HTTP
HTTP is a series of requests and responses which enable your web browser to connect to and interact with websites. The HTTP response (the one being sent by the web server to the browser) consists of two parts: the response header and response body. The response header contains metadata (the information about the data itself) such as the timestamp of the response and content type. The response body contains the content which is going to be displayed.
What is an HTTP Method?
An HTTP Method indicates the action which the HTTP request expects the web server to make. Some common HTTP Methods are ‘GET’ and ‘POST.’
What is an HTTP Request?
The HTTP Request contains two parts: the header and the body. The request header contains metadata of the request, such as client’s browser and what data is being requested. The request body contains the content of the information which the request is transferring. Any information being sent to the web server is contained in the request body.
What is an HTTP Response?
An HTTP response is the data which is received by the web browser from the web server. If the web server is able to successfully process the HTTP request, the web server returns valuable information based on that request. Just like the HTTP request, the response has a header and body. However, what makes the structure of it different is the HTTP status code. The status code is just a three digit number used to indicate if the HTTP request was successful or not. The most known status code is 404, which indicates an error due to the designated page not being found.
There is a lot of information about HTTP, so if you are looking to learn more about the protocol, make sure to read this blog.
HTML
HTML is a markup language rather than than a programming language. This means that it is a way of describing data. HTML uses tags such as <html></html>. I will not be going over HTML code in this blog, but if you are looking to learn the language, I would highly recommend going to w3schools for more information. It is important to note that HTML does not change based on user input. Therefore, it will need to used with a programming language to add functionality to the website.
JavaScript
Speaking of programming languages, JavaScript is exactly that. It can make changes to HTML even after the page loads. For example, a user can add a button which gives an alert each time a client clicks it. Since the Javascript code is executed in the user’s browser, it can be seen in the source code of the page. That is why JavaScript is a client-side language.
PHP
PHP, on the other hand, is a server-side programming language. The difference between JavaScript and PHP is that the PHP code is executed in the web server. The result of that execution is then sent as an HTTP response. Server-side programming languages allow for e-commerce and other interactive sites to work because they hide valuable information from being seen in the source code. When a user registers on a website, their username and password are stored in a database by the server-side language. Then, when that user looks to login again, the user’s input will be matched with the information in the database.
Conclusion
The convenience of modern technology blinds us to how complex the processes are for the websites and apps we use everyday. There are several different languages and protocols which are used to ensure that a user is able to get a response for their input whilst keeping their information secure. I hope this blog helped you understand a little bit more on what actually happens when you are using a website.