Saturday, 13 October 2018

Server sent response but Client not loading the sent content

I have simple node server (nodejs + express + ejs rendering), when user tried to load a particular page server sends that compiled html and sends that in response.

In order to track users I have added 2 counters

a. counter which increments when server receives request for that page

b. when client loads the page it contains one some code which will make HTTP requests back to my server which I use as counter

Now the issue is that as time passes on the difference between sentResponse counter and clientLoad counter increases increases so much so that I get sentResponse = 7000 and clientLoad = 3600.

Any suggesstions on what could cause that kind of behavior

Note: I also have setup Cloudfare before requests reaches my server and I paused it but still I was getting huge differences ?

Note: I also noticed that lots of users are making requests to the page frequently like multiple times under 4s but I am sure that I am sending valid html and I different is almost 50% so I dont think that every user that visits the page is pressing ctrl+r 2 or more times under 4s.

Code:

server.js

app.get('/dashboard', (res, res) => {
    ...
    ...
    ...

    Tracker.incrementCount('sentResponse');
    res.render(page.ejs, {...});
});

app.get('/client-load-start', (req, res) => {
    Tracker.incrementCount('clientLoadStart');
    res.send(200);
});

page.ejs

<html>
    <head>
        ...
        <script src='/client-load-start'></script>
        ...
    </head>

    <body>
        ...
        ...
    </body>
</html>



from Server sent response but Client not loading the sent content

No comments:

Post a Comment