Overview - Page and action caching
What is it?
Page and action caching are techniques in Rails to store the output of web pages or controller actions so they can be quickly served without running the full code again. Page caching saves the entire HTML page as a static file, while action caching stores the result of a controller action but still runs filters like authentication. Both help speed up websites by reducing repeated work.
Why it matters
Without caching, every visitor causes the server to run all the code to build pages, which can slow down the site and use more resources. Caching makes websites faster and more responsive, improving user experience and saving server costs. It is especially important for pages that don’t change often but get many visitors.
Where it fits
Before learning caching, you should understand how Rails controllers and views work to generate pages dynamically. After mastering caching, you can explore more advanced caching like fragment caching, Russian doll caching, and HTTP caching to optimize performance further.