# Access ResponseCache instance during extension activation?

**URL:** <https://www.ruby-forum.com/t/access-responsecache-instance-during-extension-activation/135112>\
**Category:** Radiant CMS\
**Created:** [April 17, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/access-responsecache-instance-during-extension-activation/135112 "2008-04-17T23:55:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [April 17, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/access-responsecache-instance-during-extension-activation/135112/1 "2008-04-17T23:55:55Z")

</div>

This is kind of a weird question, but is there a way to access the  
current ResponseCache instance during the activation method of an  
extension?

I’d like to be able to call its clear method to empty the cache when I  
start up a specific extension, so I don’t have to manually empty it.

Thanks!

- Dave

---

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [April 18, 2008, 12:07am UTC](https://www.ruby-forum.com/t/access-responsecache-instance-during-extension-activation/135112/2 "2008-04-18T00:07:41Z")

</div>

ResponseCache.instance should do the trick.

Sean

---

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [April 18, 2008, 4:13am UTC](https://www.ruby-forum.com/t/access-responsecache-instance-during-extension-activation/135112/3 "2008-04-18T04:13:26Z")

</div>

Sean C. wrote:

> ResponseCache.instance should do the trick.

Earlier today I tried:

cache = ResponseCache.instance  
cache.clear

… and also …

ResponseCache.instance.clear

Both deleted all the files from my /public directory instead of my  
/cache directory. What seemed to be happening was that I was creating a  
new instance of ResponseCache, which I believe by default Rails assigns  
/public as the cache directory, hence the killing of my files.

This seemed weird to me because the following (when used during any  
extension’s activation method) properly overrides the value set in  
/config/environments/development.rb for all pages in the website:

ResponseCache.defaults[:perform\_caching] = false

- Dave
