HTTP verb: GET
This course covers the HTTP GET method, the most common way a client asks a server for data. It explains why GET is safe and idempotent and how a request is built from a URL and headers with no body. It also shows what a response contains: status code, headers and body. It then looks at query strings, URL encoding and caching with Cache-Control, and at tools such as the browser, curl and API clients. The last part shows how Rails routes GET requests, reads params and builds links.
What you'll learn
- ✓Why GET is read-only, safe and idempotent
- ✓How a GET request uses the URL and headers instead of a body
- ✓Status codes, response headers and the response body
- ✓Query strings, key-value pairs and URL encoding
- ✓Caching GET responses with the Cache-Control header
- ✓Handling GET requests in Rails with routes, params and link_to
What is the GET method?
Imagine you walk into a restaurant and ask the host to see the menu. You aren't ordering anything or changing anything: you are just requesting information. In the web development world, when a browser asks a server for information, it uses the GET method.
Read the full lesson free →Curriculum
7 lessonsWhat is the GET method?
Introduces GET as the read-only HTTP method for retrieving data, and explains safety and idempotency.
Anatomy of a GET request
Shows how a GET request carries everything in the URL and headers, since it has no body.
The response of a GET request
Explains the status code, response headers such as Content-Type, and the body that holds the data.
Query parameters in depth
Covers query strings, key-value pairs joined with ampersands, and how spaces are encoded as plus or %20.
Caching GET requests
Describes how browsers cache GET responses, how Cache-Control sets duration, and why POST is not cached.
Tools for making GET requests
Compares the browser, the curl command and API clients like Postman and Insomnia for sending GET requests.
GET requests in Rails
Shows how Rails routes GET requests, exposes query parameters in params, and creates links with link_to.