允许服务器端缓存在`fnServerData`的数据表缓存、服务器端、数据表、fnServerData

2023-09-11 22:32:55 作者:感情喂过狗

在默认情况下在数据表Ajax调用避免缓存,加入一个假的领域上的网址,例如: http://yoursite.com/api/?_348522852542。我想禁用此。看来,ajax的函数调用 fnServerData ,其定义是这样的...

By default Ajax calls in DataTables avoid caching by adding a bogus field onto the url, e.g. http://yoursite.com/api/?_348522852542'. I would like to disable this. It appears that the ajax functions call fnServerData which is defined something like this...

    "fnServerData": function ( sUrl, aoData, fnCallback, oSettings ) {
        oSettings.jqXHR = $.ajax( {
            "url":  sUrl,
            ....
            "cache": false,
            ....
            });
      };

我想要的值高速缓存,而不是。我失去了一些东西?这是为什么硬codeD中也是这样吗?就是做此更改本地或通过提交补丁编辑源代码的最佳方式?

I want the value for "cache" to be true rather than false. Am I missing something? Why is this hard-coded in like this? Is the best way to do make this change to edit the source either locally or by submitting a patch?

推荐答案

您可以覆盖fnServerData回调: HTTP ://datatables.net/usage/callbacks#fnServerData

You can override the fnServerData callback: http://datatables.net/usage/callbacks#fnServerData