I manage an application that has an irregular update schedule that requires live fixes and also deals with realtime data. I want to notify clients (currently just web clients) that a new version is required if they have happened to leave the browser window open (happens a lot with our customers) for a long time and miss an update. My proposed solution is to include the version of the client in the header of every call to the server, and if the server identifies that the version header is out of sync it will return a status code that will trigger a notification informing the user to refresh the app. The app is an angular SPA hence the need for this as it's possible to stay inside the app permanently without calling for the index page again. What is the most suitable status code to use for this? Another option is having a polling system to check the version but because the application is realtime try to limit async tasks.
Currently the site page caches and uses e-tag to identify if the page has changed. This works fine as long as the user actually makes a new request for the index.html page which does not always happen.
HTTP status codes tell the client information about the resource being requested. They don't tell the client information about a different resource.
I'd consider reverse your proposed approach. Use a custom response header along the lines of ExampleDotCom-API-Version: 2023.08.31
or ExampleDotCom-Min-Client-Version: 2023.08.31
and have the client check that header to see if it supports that version of the API (and to check for an update to the client if it isn't).