Forum: Ruby on Rails Different page caching folder for different domains

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-03-24 22:07
Hi,

I created a multi-domain application, and I wanted to add page caching,
how can I tell Rails that it should save each cached page under a
subfolder such as public/www.mysite1.com/ and public/www.mysite2.com
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (conradwt)
on 2009-03-27 08:34
(Received via mailing list)
On Tue, Mar 24, 2009 at 2:07 PM, Fernando Perez <
rails-mailing-list@andreas-s.net> wrote:

>
> Hi,
>
> I created a multi-domain application, and I wanted to add page caching,
> how can I tell Rails that it should save each cached page under a
> subfolder such as public/www.mysite1.com/ and public/www.mysite2.com


If you're using page caching, then the cached page should located
relative
to
the root of your website.  Thus, if you were to access the index page on
both
www.mysite1.com and www.mysite2.com, the you should be able to find an
index.html in the following locations:

URL:  www.mysite1.com/index.html      On Disk:
 /rails-app1/public/index.html
URL:  www.mysite2.com/index.html      On Disk:
 /rails-app2/public/index.html

Now, if you really want to change the location of the cached pages to
use
another
directory other than the above, you can do the following:

Moving your Page Cache

First you'd want to add the following to your */config/environment.rb*:

config.action_controller.page_cache_directory = RAILS_ROOT +
"/public/cache/"

This tells Rails to publish all your cached files in the /public/cache
directory. You would then want to change your Rewrite rules in your *
httpd.conf* to be:

12345

  # Rewrite index to check for static  RewriteRule ^/$
cache/index.html [QSA]  # Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ cache/$1.html [QSA]


If you would like to learn more about the wonderful world of caching, I
would recommend reading the following:

http://railslab.newrelic.com/

Good luck,

-Conrad
This topic is locked and can not be replied to.