Consider a Rails app using page caching. When the cached page is expired, what is the next behavior when a user requests that page?
Think about how caching helps serve fresh content after expiration.
When a cached page expires, Rails runs the controller action again to regenerate the page and updates the cache. This ensures users get fresh content.
Identify the correct way to enable action caching for the show action in a Rails controller.
Look for the exact Rails method name for action caching.
The correct method to enable action caching is caches_action. The others are either misspelled or relate to page caching.
A Rails app uses page caching, but after updating the database, the cached page still shows old data. What is the most likely cause?
Think about what triggers cache refresh in page caching.
Page caching serves static files. If the cache is not expired or deleted after data changes, the old cached page remains served.
Choose the statement that best describes a fundamental difference between page caching and action caching.
Consider how each caching type interacts with the Rails stack.
Page caching saves the full HTML as a static file served directly by the web server, skipping Rails. Action caching still runs controller filters before serving cached content.
Given the following Rails controller snippet with action caching enabled, what will be the value of @count after two consecutive requests?
class ItemsController < ApplicationController caches_action :index def index @count ||= 0 @count += 1 render plain: "Count: #{@count}" end end
Remember how action caching serves cached content without rerunning the action.
Action caching caches the entire response after the first request. The controller action does not run on the second request, so @count stays at 1.