Excessively long URLs Coming from Datatables Dynamic Data Requests

Excessively long URLs Coming from Datatables Dynamic Data Requests

jfoster33jfoster33 Posts: 2Questions: 0Answers: 0

I'm using Datatables + Jquery + DRF for dynamic pagination.

I have a customer that uses a corporate proxy that when combined with the long datatables request URLs hit the default buffer-size limit for uWsgi. (Evidenced by an error "failed (104: Connection reset by peer) while reading response header from upstream, client..." in nginx.

This was very difficult to debug, because the URL length worked fine from my machine which was not behind a proxy. The simple fix was to increase the buffer-size in the uwsgi configuration.

However, it would be better to not allow Datatables to construct URLs of such great length. Below is an example URL generated from Datatables at this customer's site.

Presumably there are a lot of repeated / unnecessary arguments added to this URL. Have I missed a configuration or misconfigured Datatables such that it creates URLs of this length?

It seems like the URL length grew longer and longer over time, as I had the customer use a new browser and it worked for a while. Oddly having them clear cache and page history did not resolve the issue, though.

https://example.com/api/something/something/something?format=datatables&draw=1&columns%5B0%5D%5Bdata%5D=plate_number&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=false&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=plate_image&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=false&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=action&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=false&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=note&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=false&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=timestamp&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=false&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=location&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=false&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&start=0&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1234567890

Replies

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    Looks like you have server side processing enabled. These are the parameters sent to the server as described in this doc:
    https://datatables.net/manual/server-side

    The more columns you have the more parameters that will be sent. You can change to a POST request to eliminate the long URL. Here is an example:
    https://datatables.net/examples/server_side/post.html

    Kevin

  • jfoster33jfoster33 Posts: 2Questions: 0Answers: 0
    edited September 2019

    Ah, thank you for that, Kevin.

    Yes, I do have server side processing enabled. There are not that many columns, but I agree this can probably be fixed by changing the endpoints to process POST data. I still think it is a bit odd that the URL lengths seemed to grow over time but oh well.

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    They will vary depending on the searches that are performed and sent in the server side request. If you use Chrome's (and probably other browsers) developer tools in the Network tab you can look at Headers of the request. At the bottom Chrome will parse them which makes it easier to see. The number of parameters may change (order) and there maybe search values in one or more parameters. This will change the size of the URL.

    Kevin

This discussion has been closed.