TWIL #001 - The HTTP QUERY Method
A new HTTP method called QUERY - basically GET with a cacheable body, solving the long-standing problem of sending complex query payloads without resorting to POST.
- #twil
- #http
- #web

This week I learnt about this new HTTP method called QUERY. Till now, we just had these:
GET: Retrieve data from the server, does not modify the server state, cacheable.
POST: Submit data to the server to create a new resource.
PUT: Update a resource on the server.
PATCH: Partially update a resource on the server.
DELETE: Delete a resource from the server.
HEAD,OPTIONS, among others: Used for metadata and other connection related queries.
Enter QUERY
Why was it needed?
There is a fundamental problem with GET. It does not accept a body/payload. So any information you need to send has to be conveyed using query parameters. These can get very long and cannot contain sensitive information.
While some tools and software accept it, most tools do not accept GET with a payload which means if you want to send a payload, you need to use POST compulsorily.
So what is the issue with POST? It is not cached by CDNs and similar tools for good reason (let's not get into the why right now)
That is exactly why we need QUERY. It is essentially GET with payload which can be cached by CDNs, browsers, etc.
Note: This post is not made to give a full understanding about QUERY and to learn more, please check out the RFC link and other online sources. Thank you!