plomino / Plomino

Powerful and flexible web-based application builder
33 stars 37 forks source link

Datagrids causing too many POST requests #738

Open ivanteoh opened 8 years ago

ivanteoh commented 8 years ago

Problem

In both datagrid_edit.pt and datagrid_read.pt templates, sServerMethod is based form method. If the post method is 'POST' and we have 10 datagrids in the form. The server could run out of instance to serve these 'POST' request, esp if a load balancer assumes all POST requests are likely to be writes and optimises them to try to prevent write conflicts.

jQuery(document).ready(function() {
    jQuery('#${fieldname}_datagrid').dataTable(` {
        'sAjaxSource': 'tojson?item=${fieldname}&rendered=true&datatables=true',
        'sServerMethod': '${form_method}',

Options

Always use GET

[√] Change sServerMethod to always GET. Since no data is sent to the server and only data read it makes sense to only use GET.

Don't use AJAX

[√] len(options/fieldvalue) less than 10 don't use any AJAX but instead load the data at render time usingaData param

User chooses

[ ] Create a new parameter for datagrid field and pass it to sServerMethod

ebrehault commented 8 years ago

I think GET requests would make much more sense in that case.

djay commented 8 years ago

We ended up doing both. Did we do a PR @ivanteoh ?