How Caching Works
Understand Barry’s automatic page caching strategy and its performance benefits.
How Caching Works
Here’s what happens behind the scenes when a route is first visited:
- User requests a page like
/blog/my-post
- Barry checks if
cache/blog/my-post/index.html
exists - If not, it runs
index.server.go
and rendersindex.html
- The result is saved to
cache/blog/my-post/index.html
- Future requests serve this static file instantly
- The HTML is returned immediately to the user
- It is then saved to disk in the background, with locking to ensure safe writes
This approach combines dynamic rendering with static speed. If your page doesn’t need dynamic data, you don’t need to include a server file - just the HTML is enough. See Server Logic for dynamic route setup.