我想减少我的应用程序加载时间,我正在使用带有rails 4.2 的Comfy ComfortableMexicanSofa cms,我想缓存整个页面,以便当用户从浏览器点击 URL 时,我的应用程序不会从 db 加载 cms 页面内容,只需从该页面加载该页面缓存。
You gotta overwrite this controller: https://github.com/comfy/comfortable-mexican-sofa/blob/master/app/controllers/comfy/cms/content_controller.rb
Just copy it into your own app/controllers/comfy/cms folder. Then wrap that render call with cache @cms_page do
. That should reduce DB access a bit. The reason why it's not there by default is because page content may include partials/helpers that are dynamic (like currently logged-in user).
If you want to have full page caching - look into Apache/Nginx caching. Rails doesn't do page caching anymore. Also Amazon's CloudFront.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.