# Action caching with multiple domains

**URL:** <https://www.ruby-forum.com/t/action-caching-with-multiple-domains/170797>\
**Category:** Rails\
**Created:** [June 22, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/action-caching-with-multiple-domains/170797 "2009-06-22T22:40:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![timrohde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/94ad74/32.png) [@timrohde](https://www.ruby-forum.com/u/timrohde)\
**Post date:** [June 22, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/action-caching-with-multiple-domains/170797/1 "2009-06-22T22:40:53Z")

</div>

I have recently setup some action caching in my Rails app and everything  
seems to be working fine. I am using file store pointing at /tmp/cache.  
The  
problem I am running into is that separate cache directories are being  
created for different domain names that point at the same server. For  
example [mysite.com](http://mysite.com) and [www.mysite.com](http://www.mysite.com) will have different cache  
directories.  
It seems like it should be easy to force these into a single cache  
directory. But I have not been able to puzzle this one out. Is there a  
config variable that can be set to override the url or is this best  
handled  
with mod\_rewrite? I have played around with mod\_rewrite in an effort to  
fix  
this issue, with no results to this point.

Any help is appreciated.

–Tim R.

---

<div class="post-metadata">

**Author:** ![timrohde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/94ad74/32.png) [@timrohde](https://www.ruby-forum.com/u/timrohde)\
**Post date:** [June 24, 2009, 3:17am UTC](https://www.ruby-forum.com/t/action-caching-with-multiple-domains/170797/2 "2009-06-24T03:17:57Z")

</div>

Just for the record I did figure out how to resolve this issue. I was  
able  
to resolve it by adding the following to my apache vhost file before the  
normal proxy rewrites.

RewriteCond %{HTTP\_HOST} !^fully.qualified.domain.name [NC]  
RewriteCond %{HTTP\_HOST} !^$  
RewriteRule ^/(.\*) [http://fully.qualified.domain.name/$1](http://fully.qualified.domain.name/$1)  
[L,R,NE]

–Tim
