We develop a Single Page Application (SPA) for enterprise clients. When we deploy a new version of our SPA we would like to upgrade a subset of clients whilst leaving the other clients on the more stable previous version. After the new version become stable we then upgrade the rest of clients. The release cycle will always go on like this but each time we may choose a different subset of clients to try the new version.
I have thought this is a pretty standard release practice for enterprise application, call it beta-release or whatever. But to my surprise I can't much useful information about how to do it for SPA. I also face some technical difficulty, e.g. when a user sends the first GET request of the SPA (say, typing the url of the SPA in the browsers) how do I send him the correct version? It involves DB query to find out the correct version for him, but how to do that in the http request/response cycle ?
I search softwareengineering, find this Why make the login page to a single page application a separate page? It is actually what I am thinking now, e.g. make the login part a standalone app apart from the rest of my SPA. So in the login process I can decide which version I should show to this user and redirect him that version.
But is there other way to achieve what I need ? I think it involves an overall design/overhaul to my current SPA architecture.
--- Update ---
I only allow a client to use one version I assign to him. A client can't use both versions. So if I design to add v1/v2 in the URL and he types the wrong version for him I will redirect him to the correct version. But I have not decided whether to add version number to URL path. This is another design choice to make.
--- Update 2 ---
A version specific url is one of tricky parts I have not thought through even after reading joshp's answer. I make some simplification for my cases before I list my question. We use subdomain to designate tenants in our multi-tenant web application, as explain here Why use subdomains to designate tenants in a multi-tenant web application? and use a wildcard DNS record to map any tenant url to the main 'front-door' url. We don't allow a tenant to use both version, either the latest or the old one.
To add version info to url, then tenant1.mydomain.com
will map to the latest version of mydomain.com
, e.g. mydomain.com/v2
, tenant1.mydomain.com/v2
also maps to the latest version mydomain.com/v2
and tenant1.mydomain.com/v1
maps to mydomain.com/v1
Here are 2 scenarios what I don't know how the server, especially the reserve proxy handle it properly. It is not a fixed rule that a tenant will always use the old version (or the latest version). It may change for each new version. If it is a fixed rule my problem will much simpler! That is the main reason I want to introduce a standalone login app.
Since the url without the version will map to the latest version, if tenant1 should use the old version this time while he always type the url without version number, how does the reserve proxy handle it programmatically.
if tenant1 should use the latest version while he type
tenant1.mydomain.com/v1
how does the reserve proxy handle it ?
In both the reserve proxy (nginx) can't just simple do URL rewrite because whether a tenant will use the latest version may change.