How to expire fragment cache when locale changes?
问题 I'm trying to use fragment cache to cache the footer and navigation bar on a Ruby on Rails Site that uses I18n. The problem is, changing the language then shows you the footer and navigation bar in the wrong language. How do you go about expiring fragment cache when locale changes? 回答1: Rather than expiring the fragment cache, you should make the locale part of the cache key, i.e. something like cache :locale => I18n.locale, ... do ... end This way different users can see different language