Home
Support Forums

Unable to route 100% traffic to non-master branch in split testing

I wanted to make use of split-testing functionality, to create an easy Maintenance mode switch. Idea was to have a branch, that has Maintenance specific code on display, that I could then route 100% of the traffic to when I need it, instead of master.

But when I try to do that, the window just refreshes and goes back to master being 100%. I tried even with 3 branches and it looks like the master has to have at least 1% for the split test to work. I am not sure if it’s a bug or not, but if not, I’d really like this functionality to be available.

You’re probably looking for redirects instead of Split Testing. Split Testing will not allow you to set 100% for another branch.

That would involve having to update netlify.toml every time I want to enable the maintenance mode, no? Split testing approach seems easier and without a need to toggle a deploy

You can also use _redirects file and make the redirect in one line. When you wish to enable maintenance mode, uncomment that line, when you wish to disable it, comment that line.

Split Testing like the name suggests is meant to split traffic. It will probably never enable support for a single branch to be used 100%. So we can file the request if you think it’s important, but it’s highly unlikely that this would change. Not saying never, because the engineers and product decision makers might think it’s useful, but even if they do, this would take some time to be available.

Can I directly access _redirects file on the running production build? I am looking into Netlify CLI, but I don’t think I see a way to directly customise it (again without having to re-deploy the site with uncommented version)

I do understand that having 100% on one branch doesn’t quite make sense from the Split Testing perspective. But when it comes to 3 branches, I think you should be able to set master to 0 and set the other two branches to 50/50 or otherwise (which I also wasn’t able to do)

You cannot change the redirects after a site deploy; you’d deploy the different redirects while you deploy.

You could certainly change your production branch to a maintenance branch, and then create a 100% split test to it. But split testing is as Hrishikesh suggested a bit of an odd way to handle this, since it is a service in beta and has many caveats including around changing production branch on your site, so just publishing a different deploy is probably the most straightforward way to do this:

That’s a shame then - I find having to re-deploy to not be as reliable as I’d like. Split testing provided 2 advantages:

  1. Instant traffic redirection, there is no wait time involved as it is with deploying a new build
  2. Traffic redirection is more reliable - even after deployment, some users might still be using the old JS packs, which is why deploying new code to set maintenance mode is not great. I think the redirects file should be reliable enough, considering its not part of the asset pipeline :thinking:

I’ve noticed there is a feature called Edge Handlers in Beta - could this be used for my use-case, of wanting to redirect traffic live, without a need to do a deploy?

That’s what you might think. But given that feature is is Beta, we’ve had complaints from users that Split Testing is returning mixed content, or not working as they’d expect it to. Plus, Split Testing would use cookies and you might have to add warnings to let users know about it.

I personally still feel _redirects is the better way to go ahead, but that’s a call you might have to make.

Edge Handlers would need a re-deploy too. However, I would assume that you can set a specific date and time once when you deploy. But not sure if that’s a good way to do this.

Gotcha, that makes sense. I guess _redirects is the best option after all. I hope in the future, there will be a built-in way to trigger maintenance mode, similarly to how it’s done on Heroku for example (with a simple switch). Thanks for all the help!