I had an a-ha moment and realised that the internet is like a big jumble sale of data exchanges. Since then my web developer self is a changed man.
The internet is like a jumble sale with lots of individual requests and responses.
Let's imagine that we, the internet user are a child at the market, with a parent. A common individual transaction might involve a client, who is a little like a parent, and the server, a salesperson, who is selling a collection of books. Hopefully this isn't too abstract and helps to explain http-requests.
Each http-request needs a client and a server. A client is often a web browser and a server can be an application on a computer that hosts a website.
When a browser wants to get information from somewhere else on the web it sends a request to a specific location (URL) and waits for a response, much like our child who wants something and has a parent communicate with our salesperson friend.
For each http-request there will be a request and a response. Here are some methods for handling our interaction:
- GET - Requests data from a specified resource.
- POST - Sends data to a server to create or update a resource
- PUT - Sends data to a server to create or update a resource
It's different to a POST request because it is Idempotent - a put request can be made multiple times and produce the same result.
- HEAD - Asks only for information about the document.
- DELETE - Deletes data from a resource.
OPTIONS - Describes communication options for a resource.
note. This video explains more about Idempotence...and cows.
GET and POST are the most common methods in use.
Important things to remember about each method:
A GET request
- can be Cached and can also be Bookmarked,
- remains in the browser,
- should not be used for dealing with sensitive information,
- has length restrictions,
- cannot modify data the get
- A POST request
+ can never be Cached or Bookmarked, + does not remain in the browser,
+ has no restrictions to data length
Hopefully this is a step towards http-request mastery. Please leave comments.