When should I use GET or POST method? What's the difference between them?

后端 未结 14 1785
-上瘾入骨i
-上瘾入骨i 2020-11-21 06:44

What\'s the difference when using GET or POST method? Which one is more secure? What are (dis)advantages of each of them?

(similar question

14条回答
  •  闹比i
    闹比i (楼主)
    2020-11-21 07:40

    The reason for using POST when making changes to data:

    • A web accelerator like Google Web Accelerator will click all (GET) links on a page and cache them. This is very bad if the links make changes to things.
    • A browser caches GET requests so even if the user clicks the link it may not send a request to the server to execute the change.
    • To protect your site/application against CSRF you must use POST. To completely secure your app you must then also generate a unique identifier on the server and send that along in the request.

    Also, don't put sensitive information in the query string (only option with GET) because it shows up in the address bar, bookmarks and server logs.

    Hopefully this explains why people say POST is 'secure'. If you are transmitting sensitive data you must use SSL.

提交回复
热议问题