Why does Wt always use Http POST request and not GET request?

Added by Luis Vargas almost 2 years ago

I was trying the hello world application with firebug and I see that this one always send and receive data using POST method. I'm not completely sure, but I know that POST is more secure. However, GET is faster and it can be used to send and receive JSON encoded data.

I am going to show that in the next picture

In the above picture you can see that the server send me

Wt._p_.response(1640295416);{var j54203=$('#ov17utx').get(0);
Wt3_2_0.setHtml(j54203,'Hello there, Luis',false);
}

Is it not better send only the data that need to be added. In this case "Luis" which is the text inserted in the textbox.


Replies (3)

RE: Why does Wt always use Http POST request and not GET request? - Added by Koen Deforche almost 2 years ago

Hey Luis,

I'm not sure why you believe GET should be faster?

The reason for the way it works is that it is only u til after the event handling has finished, Wt knows how many widgets and how they should be updated. In general it will be more than one compared to this simple example.

In a traditional framework there may be a need for several RESTful ajax calls instead of just the one used by Wt, and that causes significant slow downs.

Regards,
Koen

RE: Why does Wt always use Http POST request and not GET request? - Added by Luis Vargas almost 2 years ago

In this webpage they say that GET request is faster than POST request

[[http://www.diffen.com/difference/Get_vs_Post]]

In this other page they say that you can use GET request for querys

[[http://ajaxpatterns.org/RESTful_Service]]

Another example is the TreeView example.

Everytime that you click any row it becomes highlighted to gray and it returns this

That means that Wt is wasting Data transfer resources. Using JavaScripts you can get the same results without asking everytime to the server.

RE: Why does Wt always use Http POST request and not GET request? - Added by Koen Deforche almost 2 years ago

Hey,

Like any solution, Wt makes a compromise. One reason for the data transfers in the example of treeview is that we want to have server-side control (in C++): as a user of the toolkit, you can still override the selection behavior for example, which would not be possible if this was implemented in JavaScript.

Where it makes sense, we implement things in JavaScript.

In practice, a Wt application will perform well as long as a single round trip (which is 130 ms cross-atlantic) is bearable.

Regards,
koen

Btw, I do not see any mention of GET being faster than POST on that page you linked ? That page actually summarizes pretty well the main reasons why Wt defaults to using POST since Wt is unaware of what kind of actions you bind to a particular event (like sending for example an email), which are not idempotent.

(1-3/3)