1 Reply Latest reply on Apr 23, 2015 2:39 AM by matias.kiviniemi

    First Ajax request really slow with Generator

    matias.kiviniemi Level 3

      Doing simple Html panel <-> Generator plugin communication and noticed a strange issue with first Ajax call being much slower than the rest. I.e. in panel javascript the first Ajax call duration is 2000ms+ the first time and then consistently ~5ms every time. On the generator plugin side durations are <2ms every time.


      I guess this could be just Chrome initializing some code, but still seems really high. Not the end of the world, but annoying anyhow. Anyone hit similar issues or any other ideas?


      Generator code

      _server = require("http").createServer(onServerRequest)


      function onServerRequest (request, response) {

      var start = new Date().getTime()


      console.log("duration=" + (new Date().getTime()-start))



      Panel javascript:

      window._ajax_start = new Date().getTime()

      $.ajax({ url: "", async: true })

        .fail(function (jqXHR, msg) { alert("service failed! message=" + msg) })

        .done(function (data) { updateData(data) })

      function updateData(data)

      alert("duration =" + (new Date().getTime()-window._ajax_start))