What is the purpose of a GET request?
Options
- Create a new resource on the server side
- Retrieve data without changing anything (Correct option)
- Delete data that is stored on the server
- Upload files from the client to the server
Answer
Retrieve data without changing anything on the server
Why
GET asks the server for data. It must be 'safe': it should not create, change or delete anything.
Because of that, browsers, proxies and CDNs may cache and repeat GET requests freely.
Never use GET for actions like /delete-user?id=5: a crawler or prefetch could trigger it.
Remember
GET = read only.