Here's a classic question that I've asked and been asked in many job interviews: "What happens when you type a URL into your browser's address bar and hit Enter?"

A good answer includes a basic explanation of DNS, networking and the structure of an HTTP request and response. But if it was a Phoenix job I might ask a follow-up: "what if the page is rendered by a Phoenix app?"

In order to answer this well, you need a broad understanding of the Phoenix stack: %Plug.Conn{}, Endpoint, the Router, plugs, pipelines, controllers and views. Then if the page is a LiveView, you also need to know about websockets and the LiveView lifecycle, including quirks such as that mount/3 is called twice. So it's a good question to test your knowledge - and studying the answer is a great way to deepen your understanding of Phoenix.

In this two-part series, I'll give the high-level overview. First I'll explain how Phoenix renders a static HTML page for routes that are served by a controller. Then in part 2 (coming soon), I'll explain what additionally happens if the route is served by a LiveView.

continue reading on arrowsmithlabs.com

⚠️ This post links to an external website. ⚠️