Skip to main content
matias.kiviniemi
Legend
April 23, 2015
Question

First Ajax request really slow with Generator

  • April 23, 2015
  • 1 reply
  • 518 views

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)

_server.listen(8080)


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: "http://127.0.0.1:8080/service", 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))

...

This topic has been closed for replies.

1 reply

matias.kiviniemi
Legend
April 23, 2015

Might be Chrome/panel init delay. If you keep Photoshop&panel open and kill & restart Generator, there is no delay. But if Generator is running, closing & opening panel gives the delay every time. In any case panel side seems to be "guilty".