Action caching per user.
Opened this issue · 4 comments
I am using "actionpack-action_caching 1.1.1" gem for applying action caching in our rails (4.2.5) application. Successfully able to cache the desired actions in controller, but when logging with other user it is showing the same cached pages of previous user. How should I cache differently for each user?
Any help is appreciated!
@vishaljagtap-tudip You can either-
- Extract user specific content to the layout (like a menu bar) and setting the
layout: false
option. - Set a cache_key to take the user_id into consideration.
@yoniamir
I have tried with your given solution but when I am using option layout: false
it is showing all html code on view page.
@vishaljagtap-tudip
Is your user specific html in a layout file? (e.g. application.html.erb)
This happened to me also. Although, I was able to cache an action but in another action where I wanted to do similar caching, Rails delivered page without setting Content Type header to "text/html; charset=UTF-8". It simply returning with "; charset=UTF-8" header. This displays page as text i.e. HTML source. Do I need to set Content Type header?