4.5.1. GET
4.5.1. GET
GET is the most common method used in HTTP. It is defined as being both safe and idempotent, meaning that a GET request should not have side effects on the server's state and that multiple identical GET requests should have the same effect as a single request.
In particular, applications need to be aware of the various ways that GET requests can be generated besides an explicit request from a user:
-
Prefetching: User agents can fetch a URL before the user explicitly requests it, to improve perceived performance.
-
Crawling: Search engines and similar tools will crawl URLs to index them.
-
Monitoring: Various tools might periodically fetch URLs to check for changes or availability.
Consequently, applications that use GET MUST NOT use it to trigger changes to server state. If an application needs to change state, it SHOULD use a different method, such as POST.
That said, it is permissible for GET to have side effects that don't affect the resource state, such as logging.
Finally, note that the query component of a URL is often used to carry identifying information. While this is a common and useful practice, it has several drawbacks:
-
GET requests with query strings are less likely to be cached than those without.
-
Query strings are visible in browser history and logs.
-
Some proxies and servers might limit the length of URLs.
Applications using GET with query strings need to be aware of these issues.