At our company, we usually design solutions as an SPA which connects to a redundant backend. We follow either of the patterns below. Clients normally don't care which pattern is followed, as long as the resources are secured properly.

SPA-to-API Connectivity Options

The major differences between them are (1) nameserver configurations, (2) CloudFront behavior on the second pattern. Otherwise, they are functionally identical.

Recently, I was asked by a client: "which pattern is better?". When they say "better", they mean: more secure, more manageable, more traceable, faster. I honestly go with option 1 because I dislike working with CloudFront behaviors. Though that's not really the answer they're looking for. I believe the two setups are functionally identical.

...but are they really? There might be a gap in my knowledge which can answer which of the two setups has an advantage from a functional standpoint. And if they are truly identical, is there a standard which prefers one over the other?

  • Also maybe cookie configuration and potentially reduced request parallelism with option 2 if you're making a lot of requests while your page is still loading static resources. Also maybe a slightly higher latency in option 2 for API calls? other than that, plenty of reputable sites doing it both ways more or less. – svidgen Oct 10 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.