Web Framework Internals interview question · Most asked
Walk through the Django request lifecycle.
Summary
WSGI/ASGI handler builds HttpRequest → MIDDLEWARE in order (request phase) → URL resolver → process_view hooks → view → process_exception on errors or template response rendering → MIDDLEWARE in reverse (response phase) → request_finished signal.
Longer Answer
Middleware that uses request.user must come after AuthenticationMiddleware, which needs SessionMiddleware. process_view can short-circuit before the view (CSRF does).
Key Points
- Middleware down, resolver, process_view, view.
- process_exception and template rendering.
- Middleware up, request_finished.
- Ordering dependencies matter.
Deep dive: Request Lifecycle: The Django Request Lifecycle and Middleware Order
Explanation
What interviewers look for
Correct order including process_view and ordering dependencies.
More most-asked Web Framework Internals questions
- How does Express handle a request, and how are errors routed?
- What is the NestJS request lifecycle?
- Describe the Spring MVC request flow and where exceptions are handled.
- What is a request lifecycle, and why should a backend engineer know it for their framework?
- Walk through the Laravel request lifecycle and say where you would add code that must run on every request.
- What layers does a request pass through before reaching application code, and how should their timeouts relate?
- Where should authentication, authorisation, validation and error formatting live in a web framework?
- What happens in the browser from navigation to an interactive single-page app?