actionpack-action_caching icon indicating copy to clipboard operation
actionpack-action_caching copied to clipboard

Action caching per user.

Open vishaljagtap-tudip opened this issue 8 years ago • 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 avatar May 18 '17 10:05 vishaljagtap-tudip

@vishaljagtap-tudip You can either-

  1. Extract user specific content to the layout (like a menu bar) and setting the layout: false option.
  2. Set a cache_key to take the user_id into consideration.

yoniamir avatar May 22 '17 14:05 yoniamir

@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 avatar May 22 '17 16:05 vishaljagtap-tudip

@vishaljagtap-tudip Is your user specific html in a layout file? (e.g. application.html.erb)

yoniamir avatar May 22 '17 20:05 yoniamir

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?

yaxhpal avatar Sep 18 '17 06:09 yaxhpal