I have a domain example.com. When a user clicks on a link (e.g. example.com/products/123) it internally computes the outgoing link, logs the click and forwards the user to the external link (e.g http://outgoing.com/123). The problem is we are trying to create a service that will work even if example.com goes down. For affiliate reasons we don't want to use http://outgoing.com/123 as the link. It should be noted, that these are often sent through emails, so the site doesn't necessarily have to be live for the user to click on the link. We can afford the loss in ability to log the click if our servers down, but don't want to lose the ability to forward the user. Is there any established methods and/or services for doing this?
Assuming that you can't try to keep example.com up at all times- ie load balancing etc, you could hypothetically ping the urls of your a tags (with a jquery script, for example) on page load. If it throws an error then switch the href attribute - far from ideal, though. If you have a number of links on the page, this could take a while.
You could also maybe do this on the back end, a routing service that pings url 1, and then moves down the line if an error response is thrown.
I had worked on a few ad platforms (years ago) that always sent people to a separate routing server and then on to their destination - for tracking purposes.