Ads Top

When to Use GET vs POST

When you don't think about the basics of development day to day, you tend to forget the how and the whys and just get in a pattern of doing. Then when you think about they why, or are asked about the why, you may not have a "definition" at the ready.

Take for example the two common HTTP methods GET and POST when communicating between a client and a server. When should you favor one over the other?





Now that we know the basics of what differentiates GET and POST, we can now go over these rules for when (or when not) to use one versus the other.

Rule 1
Use GET for save actions (retrieving data) Use POST for unsafe actions (inserting or editing data)

Rule 2
Use POST when dealing with sensitive data

Rule 3
Use POST when dealing with long requests
The max URL length limit is 2048. This affects GET (point 4 on the GET graphic above)

Rule 4
Use GET in Ajax environments.
XMLHttpRequests implement POST as a 2 step process (sending headers first then data). Thus, GET requests are more responsive.

3 comments:

  1. Jammy Robinson: Poker for free online | Casino - JTM Hub
    Jammy 남원 출장샵 Robinson is a new Poker Room with a brand new 창원 출장샵 Poker Room 광명 출장안마 with all the 김천 출장안마 latest tournaments and tournaments from the Jammy 군포 출장샵 Gaming Poker community.

    ReplyDelete
  2. In order to accommodate all users, the library will solely allow patrons to print WaterProof Double Sided Tape one project per 30 days. The library reserves the proper to not print tasks might be|that might be|which may be} used as a weapon, obscene, or protected by copyright. We are the pioneers in 3D printing know-how in Madurai serving to dentists get dental implants 3d ... We are the pioneers in 3D printing in Madurai promoting 3D printers, doing training in ...

    ReplyDelete

Powered by Blogger.