Down the caching-hole: adventures in 'HTTP caching and Faraday' land
Blog post from StackBlitz
In an exploration of HTTP caching and the Faraday library, Svyatoslav Kryukov recounts his attempt to implement an automated caching system using Octokit and Faraday, which led to unexpected performance issues due to memory bloat. The article delves into the intricacies of HTTP caching, including how Faraday middleware can be configured to manage API requests, and explains the role of cache headers such as Cache-Control and Vary. Kryukov details how Octokit's integration with Faraday allows for customizable request processing, but highlights the challenges encountered when the default URL-keyed caching strategy resulted in inefficient handling of private requests. To address these issues, Kryukov introduces a new concept of strategies in the caching middleware, enabling a more efficient caching mechanism by using the ByVary strategy to generate cache keys based on Vary header values. The narrative serves as both a technical guide and a cautionary tale about the complexities of caching in web applications, illustrating the importance of understanding underlying technologies to effectively optimize performance.