WApplication::unload() not being called
I am trying to do some cleanup when a user navigates away from my application, and I understand WApplication::unload() is an appropriate place to do it. However, I am finding that unload() doesn't always get called when the user navigates away. For example, with Firefox it seems to be called when the user presses Back, but not when they close the tab. With Chrome, it seems to be called when they close the tab, but not when they press Back. Is this expected?
I know I could put the cleanup in the WApplication destructor, but that doesn't get called until the session times out, and I need to do some cleanup right away.
If you want to do a cleanup more quickly then there is no other choice but reducing the session timeout parameter (at the expense of more keep-alive requests).
I see. So this is a browser issue, rather than a Wt issue? What is the mechanism by which WApplication::unload() is called?
A XMLHttpRequest is being sent by the browser in the window onunload() event.