Okay
  Public Ticket #3086156
slow loading
Closed

Comments

  • Anna started the conversation

    Hi, I'm really liking this plugin. It's working quite nicely for my needs. However one big issue I am having as I use more data and filters is load time is extremely slow and keeps crashing. I often get the error 'Error
    cURL error 28: Operation timed out after 5001 milliseconds with 0 bytes received'. I constantly have to refresh to try and get it to work.  Im using data connected from a google sheets which constantly updates. The data in the google sheets is from a few tabs which feeds into the connected tab which has about 18000 rows in it and five columns. Is the number of rows (18000) making it slow or would it be another issue? In other words can wpdatatables handle a google spreadsheet of 18000 rows?

    Thanks

  •  2,572
    Aleksandar replied

    Hello Anna

    The number of rows certainly is high. wpDataTables that are linked to external sources (Google Spreadsheet, Excel, CSV, etc) are non-server-side tables and they pull all the data from the source, add it to the page, and then split the table into table-pages using javaScript. While this is OK for small datasets (up to 2.000 - 3.000 cells), it can slow down or even break the page if the data gets bigger.

    You can try the following, but I don't have high hopes that you'll be able to pull a large dataset even with these modifications:

    1. If you're using the API method:

    This error is returned by the function wp_remote_get which uses cURL in the background. The client's server doesn't have time to manage the data from Google's API in 5 seconds (which is the default setting in WordPress).

    That limit can be increased using a hook https://wordpress.stackexchange.com/questions/341357/wp-remote-get-curl-error-28-only-on-same-domain. Instead of "15" set it to "100", just in case.

    If you get this error because of the WordPress hook extend_http_request_timeout, you need to remove it from your functions.php file and then checkout solutions for the first initial error for curl error 28 - Operation timed out ...

    https://www.wpbeginner.com/wp-tutorials/how-to-fix-curl-error-28-connection-timed-out-after-x-milliseconds/

    2. If you're using the old method (without Google's API credentials) the timeout limit is set to 25 in file wp-content/plugins/wpdatatables/source/class.wdttools.php on line 198.

    This can be overwritten with the hook wpdatatables_curl_get_data. For example:

    function filterCURLOptions($data, $ch, $url){
       $new_ch = curl_init();
       $timeout = 1000;
       $agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0';
            curl_setopt($new_ch, CURLOPT_URL, $url);
            curl_setopt($new_ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($new_ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            curl_setopt($new_ch, CURLOPT_USERAGENT, $agent);
            curl_setopt($new_ch, CURLOPT_REFERER, site_url());
            curl_setopt($new_ch, CURLOPT_FOLLOWLOCATION, true);
            $data = curl_exec($new_ch);
                if (curl_error($new_ch)) {
                    $error = curl_error($new_ch);
                    curl_close($new_ch);
                    throw new Exception($error);
                }
                if (strpos($data, '<title>Moved Temporarily</title>')) {
                    throw new Exception(__('wpDataTables was unable to read your Google Spreadsheet, probably it is not published correctly. <br> You can publish it by going to <b>File -> Publish to the web</b> ', 'wpdatatables'));
                }
                $info = curl_getinfo($new_ch);
                curl_close($new_ch);
                if ($info['http_code'] === 404) {
                    return NULL;
                }
       
        return $data;
    }
    add_filter('wpdatatables_curl_get_data','filterCURLOptions', 10, 3);
    

    This needs to go to the functions.php file of your theme or the child theme (depending on what you're using).


    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Anna replied

    Thanks so much for your detailed response.

    Might be a silly/ basic question, but the first solution you posted where you create the hook- where do you actually paste the filter into?

  •  2,572
    Aleksandar replied

    What do you mean Anna?

    Hooks and filters are usually added to functions.php file of your theme or child theme.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Anna replied

    hi I have now limited the number of rows in my table (about 240 rows and 5 columns now). 

    The table loads perfectly the first one or two times. Then I get the curl error 28 : Operation timed out after 5000 milliseconds with 0 bytes received,again. 

    Tried in private browsing, loaded perfectly the first time. Then curl error 28 the second time. 

    Any suggestions? Love this plugin as it does pretty much everything we need except for this big issue which means it can’t actually be used on our site. 

  •  2,572
    Aleksandar replied

    Hello Anna

    There is nothing new I can suggest about this issue.

    This error only appears in Google Sheets-based tables, and it's coming from Google, not wpDataTables. 

    Google's server, to which wpDataTables is connecting has its own method of establishing the connection, and we're using PHPs logic to connect to it. If there are errors your server returns, those are returned by the server, and only displayed by wpDataTables.

    Unfortunately, this response from 3 weeks ago is still the only response I can provide. Our developers are working on bypassing this issue but since it's coming from Google, other than increasing the quota in your Google account, I don't believe there's anything more they will be able to do in the near future.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables