Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any performance difference when using different HTTP methods?

I know how HTTP methods work and for what they are designed, but I'm curious to know if some methods are faster than others when using just to get data.
In the team I'm working on I noticed a lot of JQuery ajax requests like this below:

$.ajax({url: "../dir/someFile.json", method: 'post', dataType: 'json',
    error: function(...){ ... },
    success: function(...){ ... }       
});

I'd obviously use a 'get' method, as no data is sent to this request. This probably happened when a teammate was copying and pasting code. This works fine also, seems there's no good reason for changing it to 'get'.

I think using 'get' method would be faster in this case, but I didn't find any source affirming that.

like image 779
Marcelo Assis Avatar asked Aug 06 '12 17:08

Marcelo Assis


1 Answers

There is some research that shows that some browsers will divide a POST request into multiple packets. This could have a performance impact, which you'd think would make the request slower. But, under tests it seems that POST can sometimes be faster. I'm not sure why this is.

In practice however, the performance difference is negligible and you should use POST and GET as intended.

Read:

  • http://loadimpact.com/blog/ajax-get-or-post-which-is-best
  • http://developer.yahoo.com/performance/rules.html#ajax_get
  • http://thinkvitamin.com/code/the-definitive-guide-to-get-vs-post/
like image 71
Adam Avatar answered Sep 21 '22 01:09

Adam