# Disabling a cache block?

**URL:** <https://www.ruby-forum.com/t/disabling-a-cache-block/125549>\
**Category:** Rails\
**Created:** [January 10, 2008, 2:14am UTC](https://www.ruby-forum.com/t/disabling-a-cache-block/125549 "2008-01-10T02:14:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [January 10, 2008, 2:14am UTC](https://www.ruby-forum.com/t/disabling-a-cache-block/125549/1 "2008-01-10T02:14:51Z")

</div>

From what I can tell, it is not possible to disable a fragment cache  
block based on conditions. One use for this that comes to mind is to  
not cache a particular fragment for admin users. Of course, I could  
cache a version of the fragment specifically for admins

\<% cache :admin =\> logged\_in? && current\_user.is\_admin? do -%\>

What I’m thinking of looks like this on the surface

\<% cache {}, :disabled =\> logged\_in? && current\_user.is\_admin? do -%\>

and it wouldn’t be a big deal to implement. Only, I’m wondering whether  
there’s another way to achieve the same out of the box.

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)
