# Micro-caching in Nginx for High Performance


- Presented on: 28-Aug-2021
- Event: Bangalore Site Speed 6th Edition
- Location: Online
- Slides: <iframe class="speakerdeck-iframe" style="border: 0px; background: rgba(0, 0, 0, 0.1) padding-box; margin: 0px; padding: 0px; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 40px; width: 100%; height: auto; aspect-ratio: 560 / 315;" frameborder="0" src="https://speakerdeck.com/player/c93733dc33cb49339ce8bdca6cdda952" title="Micro-caching in Nginx for High Performance" allowfullscreen="true" data-ratio="1.7777777777777777"></iframe>
- Video: <iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/termdb4vepA?si=Oa2F-okayZE1hRIS&amp;start=2199" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
- Tags: Performance, Web Development, Hosting
- URL: https://miranj.in/blog/2025/micro-caching-in-nginx-for-high-performance


In the vast, multi-layered subject area of web performance, server response time is an important metric. From a CMS standpoint, however, it is one of the most significant. Best practise recommends a 200ms or lower time-to-first-byte. For medium to high-traffic sites, server load is another vital statistic.

We were invited to talk about our learnings from optimising and hosting high-traffic sites such as [Guiding Tech][gt] at the [sixth edition](https://www.meetup.com/bangalore-site-speed/events/279778427/) of the [Bangalore Site Speed Meetup](https://www.meetup.com/Bangalore-Site-Speed/).

<div class="stretch clearfix" style="clear: both"><div class="embed-16-9">
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/termdb4vepA?si=Oa2F-okayZE1hRIS&amp;start=2199" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></div>

<p class="caption"><a href="https://www.youtube.com/watch?v=termdb4vepA&t=2199s">Bangalore Site Speed Meetup 6th Event</a> on YouTube.</p>

In this talk we go over caching as a broad performance strategy, before dive into micro-caching as a specific approach to handle loads of 10 to 100 concurrent requests per second. We cover the filter, storage, and invalidation implementations[^1] of this caching strategy in [Nginx][]. The talk concludes by comparing metrics of our caching strategy against a target of achieving sub-200ms TTFB response times for all visitors.

_This talk is a newer revision of the [_Fortifying Craft CMS for High Traffic_](https://miranj.in/blog/2020/fortifying-craft-for-high-traffic) talk from 2019[^2] which, as it says on the tin, was specifically tailored for [Craft CMS][craft] based workflows. In this edition we focus on just micro-caching as a strategy and look at it independent of any specific CMS running at the application layer._

[^1]: The sample [Nginx config file from this talk](https://gist.github.com/rungta/e35bd486e9439da46d9796cd12faae1f) is available on GitHub.
[^2]: Delivered at [Dot All 2019 in Montreal, Canada](https://craftcms.com/events/dot-all-2019/sessions/fortifying-craft-for-high-traffic).

*[TTFB]:Time to First Byte

[gt]:https://miranj.in/work/guiding-tech
[nginx]:https://nginx.org/
[craft]:https://craftcms.com/