page cache in rails
My home page is largely the same for all users, which makes it a candidat开发者_StackOverflow社区e for page caching. however, there are a couple of things that are user specific. For example, there is a nav item that is only shown for logged in users and there is a link like logout, my profile etc, generated for specific users.
Do I have to use fragment caching instead? or should I use page caching and embed fragment caching for these specific items? or what other ways can this be accomplished.
Also, the nav bar is generated in a plugin (simple-nav), how do I control what is generated inside the plugin with regards to caching?
Thanks
In this situation you are largely limited to fragment caching.
For a plugin you will probably have to have a look at the source in order to make a call about how caching can be handled. If the plugin generates the nav as some content that you push into a template, you can cache this fragment.
Depending on your audience, you might be able to push the non-cached elements to JS. You can cache the entire page and then use JS to flip the login/logout links. Really hardly worth the effort.
As with any performance optimisation,. Have you measured the performance of your system and collected metrics?
精彩评论