Node.js: 304 Statuses and how to avoid them?

I am having a problem with my server connects not running because of a 304 status. Why? And how can I get rid of it?

Screen Shot 2022-05-04 at 3.58.11 PM

user_logout is my security provider logout action
user_logged_in is my check to see if user is logged in

When I log out it should run the logout and reload the user_logged_in sc.

Have you tried disabling cache?


I’ll try that in the morning. But it doesn’t give me much confidence in node if I have to rely on users to have caching turned off.

I’m actually trying to follow your node videos and having problems just with the log out.

Update: disabling the cache got rid of the 304 status but still didn’t log out properly. Have to keep spamming the logout button and eventually it works. I’ll investigate further in the morning.

1 Like

when you are saying it is not logging out properly, what is it doing?

That’s a very interesting thing, does this happens on localhost or just on the remote server?

If it happens on localhost the Wappler team might have to step in. And definitely, you should not tick the browser’s “Disable cache”, as that only solves the problem for you

If it happens just on the remote server, your web server might be overriding some HTTP cache parameter (initially set by NodeJS), causing those pages to be cached even when you don’t want. In that case, can you tell us more about your setup?

I only have the localhost Wappler server, I don't have remote Node hosting to be able to test it there. When I click on the logout button it does give a 200 status (with caching turned off) for the logout server connect but nothing happens. Have to repeatedly click on the log out button and eventually it works. I am going to redo the log out process today. But I see no reason why it shouldn't work.

Try a new site with the Git repository. From there, you can figure out what has gone wrong.

A 304 status is not an error, it is a warning that the files have been loaded from the browser’s cache because there was no change in the files. That is why I suggested to disable the cache. It is a good habit to disable the cache while developing a site, just in case.

Solved! Thanks @ben! Comparing what you did to what I did I found one simple little mistake. On button click I had the user_logged_in server connect to ‘load’. Changing it to ‘reset’ solved everything. This must be a difference between php and node.js?

But, anyways it’s working!

1 Like

What do you mean Brad? Can you share a screenshot of this?

This Works …

<button id="btnLogOut" class="btn btn-primary btn-sm" dmx-show="" dmx-on:click="scUserLogOutForm.load();browser.goto('/',true);scUserLoggedIn.reset()">Logout</button>

This doesn’t …

<button id="btnLogOut" class="btn btn-primary btn-sm" dmx-show="" dmx-on:click="scUserLogOutForm.load();browser.goto('/',true);scUserLoggedIn.load()">Logout</button>

The only difference is my user details sc (scUserLoggedIn) is set to reset on on button click instead of load.

What is:


Is this a form? Or what?

No, it’s not in a form. It’s attached to a Button on click attribute.

The question is what are you doing with the following button and dynamic actions attached to it?

<button id="btnLogOut" class="btn btn-primary btn-sm" dmx-show="" dmx-on:click="scUserLogOutForm.load();browser.goto('/',true);scUserLoggedIn.load()">Logout</button>

You have 3 dynamic events - what are they doing?
First of all - why call logout and redirect to / both on click? What’s the purpose of loading this scUserLoggedIn.load() on the same click event - what does it do?

On logout all you need to do is to load the logout server action … all other events should be controlled by the logout action, not loaded next to it on the click event. That is wrong.
Maybe explain what each of these do and what exactly are you trying to achieve.

Runs the logout action on mouse click.

On Button click redirects to homepage when logged out in case user logs out in an admin page. Note: I haven't secured the pages yet. Still need to figure that part out. This action may not be needed after pages secured.

Reloads the user details query to hide menu and show login button.

Brad, on click you only should run the LOGOUT server action and nothing else.
On logout server action SUCCESS event you run everything else that needs to happen AFTER logout is done. You can’t run 3 dynamic events on single click as you don’t know when one has finished and start another. The whole concept here is wrong.

Well, I thought of the SUCCESS event but since there is no form there is no on Success? I am very curious as to what the proper procedure is. I need the recordset to reload after log out to hide the menu.

What do you mean there is no success event available?
You select the logout server action and select dynamic events > success … you can add actions there.

And you should only run the logout server action on logout button click, nothing else. This has been like that since ages.

1 Like

Thank you. I am redoing my logout now. Thanks for pointing me in the right direction! :beers:

Update: Cool, I learned something new today! Much appreciated.

1 Like

You are right @Teodor, when discussing the logout part only.

But the part that @brad is talking about is the monitoring of a logged-in-person (UserLoggedIn).

A logged-in-person will change the login button to a logout button and also make personal details available.

When a user logs out, the the logged-in-person status must change to reflect that. This is done by resetting the UserLoggedIn dataset.

The following is the code for the logout button:

<button id="btnLogout" class="btn" dmx-show="" dmx-on:click="scLogout.load();scUserLoggedin.reset();notifies1.success('You are now logged out.')">Logout</button>

Normally, a load instruction would be sufficient. But in this case a reset is required:


This is where the problem was. @brad used load. He has now changed that to reset and all is well.

1 Like