Start here. This is the direct spoken answer to practice first.
Overview
Middleware is a nested call stack, so placement decides which requests and responses a component can observe or repair.
ASGI middleware wraps the application in layers. A request enters the outer layer and moves inward; the response or exception moves back outward in reverse. Therefore order determines whether authentication context, timing, compression, CORS headers, or error handling is already available when another layer runs. I identify the actual outer-to-inner stack from how middleware is registered instead of assuming the source-code list reads like execution order.