# Production and cache

**URL:** <https://www.ruby-forum.com/t/production-and-cache/172447>\
**Category:** Rails\
**Created:** [July 21, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/production-and-cache/172447 "2009-07-21T17:52:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alesc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@alesc](https://www.ruby-forum.com/u/alesc)\
**Post date:** [July 21, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/production-and-cache/172447/1 "2009-07-21T17:52:21Z")

</div>

Hello!  
i have made a multisite system.

Depending on the url of the request (www.clerk.it / www.fastshare.it /  
…) it generate a different website, this is the fron-end, each sites  
have a different back-end too where the user can manage a lot of  
different thing based upon the installation configuration (it’s  
basically a CRM + ERP) so it’s content can change every second.

Now my problem is the following, if i enable caching in production  
enviroments the system will not send the correct resource (some image as  
attachment), this is caused by the fact that the url except for the  
domain name are the same so the caching system find a page named “index”  
and send it, even if it’s not the correct one.

My question is: can i set a different cache directory based on domain  
name? if yes… how? (i have to add a new site without restarting the  
service of course…)

---

<div class="post-metadata">

**Author:** ![alesc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@alesc](https://www.ruby-forum.com/u/alesc)\
**Post date:** [July 21, 2009, 7:12pm UTC](https://www.ruby-forum.com/t/production-and-cache/172447/2 "2009-07-21T19:12:47Z")

</div>

Somehow I thought that was how it worked by default. For example, my  
site  
caches files as:

~/thepeoplesfeed/tmp/cache/views/www.thepeoplesfeed.com/…

What cache are you using? I’m not sure the memory cache splits things  
by  
domain.

On Tue, Jul 21, 2009 at 11:52 AM, Alessandro S. \<  
removed\_email\_address@domain.invalid\> wrote:

> Now my problem is the following, if i enable caching in production  
> [http://www.ruby-forum.com/attachment/3889/screenshot.zip](http://www.ruby-forum.com/attachment/3889/screenshot.zip)
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

# –

Jim  
[http://www.thepeoplesfeed.com/contribute](http://www.thepeoplesfeed.com/contribute)

---

<div class="post-metadata">

**Author:** ![alesc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@alesc](https://www.ruby-forum.com/u/alesc)\
**Post date:** [July 22, 2009, 10:32am UTC](https://www.ruby-forum.com/t/production-and-cache/172447/3 "2009-07-22T10:32:00Z")

</div>

I have read a lot this few days about caching in ruby…

I see that the only solution for me is to use cache action and part of  
the view… a really hard work (ps under tmp/cache i have no files)

James E. wrote:

> Somehow I thought that was how it worked by default. For example, my  
> site  
> caches files as:
> 
> ~/thepeoplesfeed/tmp/cache/views/www.thepeoplesfeed.com/…
> 
> What cache are you using? I’m not sure the memory cache splits things  
> by  
> domain.
> 
> On Tue, Jul 21, 2009 at 11:52 AM, Alessandro S. \<  
> removed\_email\_address@domain.invalid\> wrote:
> 
> > Now my problem is the following, if i enable caching in production  
> > [http://www.ruby-forum.com/attachment/3889/screenshot.zip](http://www.ruby-forum.com/attachment/3889/screenshot.zip)
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > >
> 
> # –
> 
> Jim  
> [http://www.thepeoplesfeed.com/contribute](http://www.thepeoplesfeed.com/contribute)

---

<div class="post-metadata">

**Author:** ![alesc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@alesc](https://www.ruby-forum.com/u/alesc)\
**Post date:** [July 22, 2009, 3:01pm UTC](https://www.ruby-forum.com/t/production-and-cache/172447/4 "2009-07-22T15:01:11Z")

</div>

James E. wrote:

> What kind of cache are you using? Could you copy your environment file  
> here?
> 
> On Wed, Jul 22, 2009 at 4:32 AM, Alessandro S. \<

It’s the dafault file, i have made no change

# Settings specified here will take precedence over those in

config/environment.rb

# The production environment is meant for finished, “live” apps.

# Code is not reloaded between requests

config.cache\_classes = true

# Full error reports are disabled and caching is turned on

config.action\_controller.consider\_all\_requests\_local = false  
config.action\_controller.perform\_caching = false  
config.action\_view.cache\_template\_loading = false

# See everything in the log (default is :info)

# config.log\_level = :debug

# Use a different logger for distributed setups

# config.logger = SyslogLogger.new

# Use a different cache store in production

# config.cache\_store = :mem\_cache\_store

# Enable serving of images, stylesheets, and javascripts from an asset

server

# config.action\_controller.asset\_host = “[http://assets.example.com](http://assets.example.com)”

---

<div class="post-metadata">

**Author:** ![alesc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@alesc](https://www.ruby-forum.com/u/alesc)\
**Post date:** [July 22, 2009, 2:37pm UTC](https://www.ruby-forum.com/t/production-and-cache/172447/5 "2009-07-22T14:37:14Z")

</div>

What kind of cache are you using? Could you copy your environment file  
here?

On Wed, Jul 22, 2009 at 4:32 AM, Alessandro S. \<
