i'm running a JavaServlet and as JavascriptApp on the same machine.
The servlet outputs the current time:
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ServletOutputStream os = resp.getOutputStream();
os.print("" + System.currentTimeMillis());
}
The JS Gets the time:
$.get("UserdataServlet", function(data) {
console.log("dy " + data);
console.log("my " + Date.now());
});
and prints sometimes values like this:
dy 1433690185937
my 1433690185935
how can that be? The time on the Servlet is taken before the Date.now() in the javascript? And both are running on the same machine.
"my 1433690185935" should always be greater or at least equal than "dy 1433690185937". But how can it get smaller
Is it some kind of optimisation from the browser?
some more examples:
GET http://localhost:8081/Planetserverlinux/UserdataServlet
dy 1433691257707
my 1433691257717
GET http://localhost:8081/Planetserverlinux/UserdataServlet
dy 1433691258716
my 1433691258719
GET http://localhost:8081/Planetserverlinux/UserdataServlet
dy 1433691259700
my 1433691259715
GET http://localhost:8081/Planetserverlinux/UserdataServlet
dy 1433691260700
my 1433691260720
GET http://localhost:8081/Planetserverlinux/UserdataServlet
dy 1433691261700
my 1433691261712
GET http://localhost:8081/Planetserverlinux/UserdataServlet
dy 1433691262704
my 1433691262701