none
JavaScript / REST slow on first run RRS feed

  • Question

  • In the solutions that we created you would open a display from for a list item and from that form you could click on a button that we added that would approve the workflow task that was associated with that item.  The process itself is working great. What we have discovered is that the first time an employee uses this button it takes a very long time to complete (30 seconds) after the initial approval the next approval will only take a few seconds to complete.    Every time I clear my cache I can duplicate the issue.

    The solution consists of jQuery and REST for accessing the correct task and marking as approved.

    Does anyone know what would cause it to be so slow just the first time it is ran.

    Tuesday, July 21, 2015 5:40 PM

All replies

  • Hi,

    It's normal to take a bit more time for the first request as all the js/css/images are downloaded and cached in the browser. For next requests these files are not downloaded, taken from browser cache.

    However 30 secs is really unexpected. You can use developer toolbar in Chrome/Firefox to trace the network requests and it'll show you the request is taking more time and from there you can check you to reduce the response time  - maybe minifying the css/js or combining multiple js files into one, or if you are using CDN network for js/css, you can probably include the files in your solution etc.


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

    Wednesday, July 22, 2015 7:01 AM
  • Thank you for this.  I utilized developer tools and found that we are really making two called the fist is a application/json call that is using REST to get information on the item that the workflow is running.  The second thing that happens is our code sets the approval task to "approved" so it is using /_vti_bin/Workflow.asmx.  The call to workflow.asmx is what is taking 30 seconds the first time.

    FIRST RUN

    json - 4.41 sec
    workflow.asmx - 31.05 sec

    SECOND RUN

    json - 93 milliseconds
    workflow.asmx - 1.17 sec

    Can anyone think of a reason why the call would take so long the first time?

    Wednesday, July 22, 2015 5:27 PM
  • Hi,

    Few questions,

    • When you say it's taking less time for second time, are you trying to approve the same task again (I mean same approved task is approved again)? Or you are trying a separate non-approved task on second run?
    • Do you have any event receiver running on task list? It might happen some event receiver running in the background while the workflow.asmx is trying to update the task?

    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

    Thursday, July 23, 2015 1:23 AM
  • Hi,

    Any update?

    Best Regards


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Monday, August 3, 2015 1:16 AM
    Moderator