When to use HTTP GET vs POST?

preview_player
Показать описание
HTTP methods Get and POST are the most popular http methods used on the web. Each carries its own differences and properties. It can confusing to get to choose when to use POST over GET. In this video we will explain the differences, use cases and the benefits of using GET and POST.

HTTP Request
Lets start with explaining the anatomy of a HTTP requests, the main components of a request
It has. URL
it has method type,
headers content-type, cookies erc
and body the content

 
Property GET POST
 
Body No Yes
 
Data Request Limit Yes (2048 bytes) No limit
 
Data Type Ascii only Any data
 
Safe Yes No
 
Idempotent Yes No
 
Caching and Prefetching Yes No
 
Bookmarkable Yes No
 
Security? No Yes

Body

GET Requests Dont have Body
Post does

Data request limit
Url + body

Data type
Get Only ascii

Get URL only (2048)
POST no limit

Caching and prefetching

Safe
Modifies the resource

Idempotency

Bookmark

You can copy the url share it to twitter and anyone will get to that resource with all that parameters

Read request that need to send lot of data to the server will have to use POST. (Like tracing)



9:10 e-tag reference

Stay Awesome!
Hussein
Рекомендации по теме
Комментарии
Автор

Wow, these videos actually explain the concepts without copying and pasting wikipedia like all the others!

pattonjapes
Автор

Awesome explaination...I am a tester and now I remember that developers used only post requests. That time I was very surprised hows it possible :D

juhiagarwal
Автор

at 8:42 I did not understand your example with the email. Would you care to explain?

LynnyrdRavage
Автор

You are best bro, i guess im addicted to your videos about network :)

erensrtky
Автор

All videos are amazing, I have been working in the security domain, for me, some network concepts were not clear, but your videos make it so easy, keep making videos, also can you make API keys vs OAuth videos from a security standpoint, when to use what

Prachivibes
Автор

You can add body to get request easily.

RashidAli-txvm
Автор

very informative, lots of things i learned . thanks

TheTwistedTraceur
Автор

Therapist: the uncanny valley of accents doesn't exist
The uncanny valley of accents:

abraruralam
Автор

Hi hussein,
I think POST itself doesn't change the data on the server, its the developer who choose to change the data or not.
So, in my opinion we can't consider POST safe because of that reason.
But We could say POST is safe maybe because its hides the parameters ( data ) that is sent.

AhmedElAtari
Автор

Nice comparison.
Idempotent was confusing.
And what is your opinion about using Headers in GET request to send small amount of data securely to server ?🙄

cool-aquarian
Автор

There is nothing that prohibits a GET request from containing a body. For example, if the URL for a specific response is becoming too long and cumbersome this information can be included within the body of the GET request to be parsed by the server. Allowing for a larger data request limit when using GET.

TheScarnak
Автор

Dear bro .
I'm looking for get and post method for one special problem and i cant found it in your video but i know you can do it .
I need to know how i can use get and post method for captcha code when the server is so busy and captcha code not shown . Do you think that its possible to appear captcha code on busy or overloaded sites by get and post method.
Tnx

aminalamdarloo
Автор

I think this video was used to train gemini

arymsg
Автор

Minor nit .. (well many not minor) .. you can technically have a body in a GET request

davidbalme
Автор

Thanks Brother, couple of questions like as usual :) I haven't seen your video about E-Tags. If you have already covered following questions in E-tags video. please ignore it.

-> 1. will pre-fetching & caching default applies to GET request like browser implements them ? or any customizations needed ?

-> 2. In the case of caching, client will always send a request to server. whether there is a change in content or not. however, imagine there is a situation where there will be no change in data for next 24 hrs. can i cache this data in localStorage object in browser with key as date. before sending request to the client. I will check whether there is data for today in localStorage object. if it is, I can use it otherwise i will send a request.. is it safe to use this pattern or localStorage implementation is based on browser like google has this. I am not sure about other browsers..

-> 3. I hope, for above pattern we cannot use pre-fetching. because browser makes a smart decision whether the request has to be sent or not. is it applies only to images and binary data.. or any other data too like simple text..

I just started my career in development field. that's the reason, i am asking so many questions... Thank you !!

harshavardhan
Автор

Very Nice explanation but instead of explaining what does GET and POST actually mean in detail, you explained other things

kanishk
Автор

Hi Hussein,
Can we cache get request, If yes then what is the use of caching get request.

AbhishekSHARMA-hefd
Автор

Thank you very much for your content, its super valuable

jakubfrei
Автор

I don't want to mix up this question with previous one's.. I am creating a new comment..


A server is not necessarily a single machine, but several server software instances can be hosted on the same machine. With HTTP/1.1 and the Host header, they may even share the same IP address.

Question : why we need to install several server software instances on the same machine. is it like, on port 80 we are using some application and another port 8080 we are running some other application.. can't we do this single server software instance ?

Thanks mentor for all the help you are providing..

harshavardhan