Page caching - Implementing Page Caching in a Rails Application with Redis

Serving whole pages from a shared cache breaks Rails forms, because every visitor receives the CSRF token that was rendered for someone else. In this post, we’ll cache public pages with Rack::Cache backed by Redis and look at two ways to keep CSRF tokens working: fetching a fresh token with JavaScript from a small uncached endpoint, and a Rack middleware that injects one on the server.

August 6, 2021 · Updated October 29, 2026 · 9 min · 1714 words · Bá Tới

Page caching - Leveraging Page Caching with Varnish in Rails Applications

Varnish can cache whole Rails pages in memory and serve them without touching the application, but only if Rails tells it which pages are safe to share. In this article, we’ll let Rails mark public pages with Cache-Control, configure Varnish to honour those headers without leaking one user’s page to another, and add PURGE/BAN invalidation.

August 5, 2021 · Updated October 29, 2026 · 7 min · 1314 words · Bá Tới

Page caching - Strategies for Web Performance Optimization

Page caching is a technique used to improve the performance of web applications by storing the entire HTML output of a page and serving it directly from the cache for subsequent requests. This eliminates the need to generate the page dynamically on each request, reducing server load and improving response times. In this article, we’ll explore the concept of page caching, the HTTP caching basics it relies on, and the main places a full page can be cached, plus related techniques that cache smaller pieces.

August 4, 2021 · Updated October 29, 2026 · 6 min · 1074 words · Bá Tới

PostgreSQL Best Practices

PostgreSQL is a powerful, open source object-relational database system with decades of active development and a proven architecture. In this post, I will share some best practices to keep your PostgreSQL database fast, from EXPLAIN and indexing to schema design and basic configuration.

September 28, 2016 · Updated October 29, 2026 · 13 min · 2626 words · Bá Tới