0
0
Ruby on Railsframework~5 mins

Page and action caching in Ruby on Rails - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is page caching in Rails?
Page caching saves the entire HTML output of a page as a static file. When a user requests that page, the server serves the static file directly without running Rails code, making it very fast.
Click to reveal answer
intermediate
How does action caching differ from page caching?
Action caching runs Rails filters and code before serving a cached version of the action's output. It allows authentication and other logic to run, unlike page caching which skips Rails entirely.
Click to reveal answer
beginner
Which caching method is better for pages that require user authentication: page caching or action caching?
Action caching is better because it runs Rails filters like authentication before serving cached content. Page caching skips Rails and cannot check user permissions.
Click to reveal answer
beginner
How do you enable page caching for a controller action in Rails?
You use the caches_page :action_name method inside the controller. This tells Rails to save the full HTML output of that action as a static file.
Click to reveal answer
intermediate
What is a common downside of page caching?
Page caching can serve outdated content if the cached file is not expired or deleted after data changes. It also cannot handle dynamic content per user.
Click to reveal answer
What does page caching in Rails do?
ASaves the full HTML output as a static file
BCaches only database queries
CRuns filters before caching
DCaches only JSON responses
Which caching method allows running authentication filters before serving cached content?
APage caching
BLow-level caching
CFragment caching
DAction caching
How do you enable page caching for an action named 'show'?
Acaches_action :show
Bcaches_page :show
Ccache_page :show
Dcache_action :show
What is a limitation of page caching?
AIt is slower than action caching
BIt cannot cache static files
CIt skips Rails filters and cannot handle dynamic user content
DIt requires database queries on every request
When is action caching preferred over page caching?
AWhen you need to run filters like authentication before caching
BWhen you want to cache static assets
CWhen you want to cache only partial views
DWhen you want to cache database queries
Explain the difference between page caching and action caching in Rails.
Think about when Rails code runs in each caching method.
You got /4 concepts.
    Describe a scenario where action caching is better than page caching.
    Consider pages that show different content to logged-in users.
    You got /4 concepts.