Page MenuHomePhabricator

QueryViz - Use GET Instead of POST for Lingua Libre's SPARQL endpoint queries
Open, Needs TriagePublic

Description

Using GET allows the browser to cache the server responses and therefore reduces the load on the server and improves the loading times (for every client after they have already loaded the page once).

Ideally, POST should only be used for big queries. How big is not entirely clear, as browsers and servers do not accept the same limits. After a quick search on the Web, it seems like 4000 bytes should almost always be OK (except with IE), but limitations might occur beyond that size.

Therefore, we need to use GET whenever possible, but still use POST whenever the payload exceeds a set point (for example 4000 bytes as mentioned above).

Good first task: it's a conditional to edit on github, then to git pull the code on the server. Result will be barely visible, yet positive.

Event Timeline

This is to fix in modules/ext.queryViz.QueryViz.js in the // Adapts to each service's xhr protocol : post vs get section.

@Elfix , what do you mean by "payload" ? The sparql query itself right ? such as

SELECT * WHERE {
  ....
}
ORDER BY ?languages

If this text length is under 4000 characters (?) then GET, else : POST.
Right ?

It seems like 4000 bytes (aka characters in our very case) should be a good limit beyond which we should always use POST as most browsers seem to accomodate well beyond that limit, with the exception of IE.

@Elfix , what do you mean by "payload" ? The sparql query itself right ?

Correct. Let me rephrase a little differently. With POST, I believe the SPARQL query is in the HTTP request payload, while the URI remains static (does not contain the SPARQL query). With GET, the SPARQL query is in the URI and the HTTP request payload is empty.

Hello @Elfix , to be honest these HTTP request payload and static URI concepts and nuances are unfamiliar and blur to me.
Would you be ok to suggest a fix in modules/ext.queryViz.QueryViz.js in the // Adapts to each service's xhr protocol : post vs get section via a PR ?
It would be the most efficient for us.
This being a quality improvement change, it can be done whenever we want to. Let me know.