0

SharePoint Rest API taking around 13 seconds to fetch data from List based on some filter conditions. This is making the app slow for the users and they are complaining. Is there a way to make the REST call a bit faster ?

Added the code which calls the REST end point.

enter image description here

function getTasks() {
    return $http({
        method: 'Get',
        url: _spPageContextInfo.webServerRelativeUrl + "/_api/SP.AppContextSite(@target)/web/lists/getByTitle('TasksList')/items?$select=*,ProjectTitle/Title,ProjectTitle/Id,ResponsiblePersons/Id,ResponsiblePersons/Title,Attachments,AttachmentFiles,TaskRequestor/Id,TaskRequestor/Title&$expand=ProjectTitle,ResponsiblePersons,AttachmentFiles,TaskRequestor&$top=9999&@target='" + spContext.hostWebUrl + "'",
        headers: {
            'Accept': 'application/json;odata=verbose',
        }
    });
}
2

If you don't need metadata about the requested list items you could change your header to:

"Accept": "application/json; odata=nometadata"

There is an additional step between 'verbose' and 'nometadata' but the name currently eludes me.

It helped greatly in my case, although it might not make much of a difference in your case with more complex filters. Ususally, I just request more data than I need (ex. all items) and filter in the application/client.

When querying 100,000 complex list items, i got a speed increase of about 50% if metadata is skipped.

  • Thanks for answer. I don't need metadata. But your solution is not working in my case. I have SP2013 on-premise. – Karthik Jul 10 '18 at 12:45
1

When we make a call with the REST API, there is a lot of additional data which we get back in the response. This additional data consists of the metadata and the Hyper Media Controls along with the required JSON data. This makes the payload size of the REST response too big. If you are developing a REST heavy application, then each extra byte of data that travels over the wire to your client adds up and ends up hampering performance. Improving REST API performance you need to explore the changes in the header of rest calls or

Source

  • Thank you for answer but the link to the post is applicable only for SharePoint Online. Is there any way for on-premise SharePoint 2013 ? – Karthik Jun 25 '18 at 7:22
  • It implies to on-premise also but with SharePoint 2013 SP1 – Sunil Sahu Jun 25 '18 at 8:26
0

I am able to improve performance by not requesting item attachments. I am fetching them on demand. The request is now taking only 3.77 seconds to complete.

The modified getTasks function is below:

function getTasks() {
    return $http({
        method: 'Get',
        url: _spPageContextInfo.webServerRelativeUrl + "/_api/SP.AppContextSite(@target)/web/lists/getByTitle('TasksList')/items?$select=*,ProjectTitle/Title,ProjectTitle/Id,ResponsiblePersons/Id,ResponsiblePersons/Title,TaskRequestor/Id,TaskRequestor/Title&$expand=ProjectTitle,ResponsiblePersons,TaskRequestor&$top=9999&@target='" + spContext.hostWebUrl + "'",
        headers: {
            'Accept': 'application/json;odata=verbose',
        }
    });
}

The screenshot showing the time is below: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.