# Caching for different roles using same controller & views

**URL:** <https://www.ruby-forum.com/t/caching-for-different-roles-using-same-controller-views/127589>\
**Category:** Rails\
**Created:** [January 30, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/caching-for-different-roles-using-same-controller-views/127589 "2008-01-30T16:22:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [January 30, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/caching-for-different-roles-using-same-controller-views/127589/1 "2008-01-30T16:22:00Z")

</div>

I use a controller and its views for both administrative and public use,  
and I prefer to do page caching instead of fragment caching. I know I  
will need to have different URLs for the depend on user roles, eg  
/articles/3/comments for public user and admin/articles/3/comments for  
administrative user. I looked into several things, but couldn’t make it  
work.

Joan

---

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [February 3, 2008, 3:35pm UTC](https://www.ruby-forum.com/t/caching-for-different-roles-using-same-controller-views/127589/2 "2008-02-03T15:35:24Z")

</div>

Joan Gu wrote:

> I use a controller and its views for both administrative and public use,  
> and I prefer to do page caching instead of fragment caching. I know I  
> will need to have different URLs for the depend on user roles, eg  
> /articles/3/comments for public user and admin/articles/3/comments for  
> administrative user. I looked into several things, but couldn’t make it  
> work.
> 
> Joan

There have been a couple of posts about page caching with admin users,  
but from memory both use cookies. Here’s one some quick googling turned  
up:

[http://blog.maxdunn.com/articles/2006/09/16/ruby-on-rails-advanced-page-caching](http://blog.maxdunn.com/articles/2006/09/16/ruby-on-rails-advanced-page-caching)

I can’t see how using different simply using different can work safely.  
What’s to stop an ordinary user from navigating to  
admin/articles/3/comments unless you have some sort of Basic  
authentication done by the webserver.

* * *

[http://pushrod.wordpress.com](http://pushrod.wordpress.com) – old dogs, new tricks  
[http://autopendium.com](http://autopendium.com) – a place your old car can call home
