rack

Custom middleware for request tracking

Rack middleware sits between the web server and Rails application, providing a hook for cross-cutting concerns like request logging, metrics collection, or custom authentication. I use middleware to inject request IDs, track response times, or enforce

Request timeout handling with Rack::Timeout

Long-running requests tie up worker threads and degrade overall application responsiveness. Rack::Timeout enforces request timeouts at the Rack layer, killing requests that exceed configured limits. I set conservative timeouts (15-30 seconds) and hand

API response compression with Rack::Deflater

Large JSON payloads consume bandwidth and increase latency, especially for mobile clients on slow connections. Rack::Deflater middleware automatically compresses responses using gzip when clients send Accept-Encoding: gzip headers. This typically redu