How can I specify the location of the fragment cache?

I am using fragment caching - the cache gets stored under RAILS_ROOT/
tmp/cache/www.mysite.com but if someone goes to http://mysite.com (no
www) then, a second cache gets stored at RAILS_ROOT/tmp/cache/
mysite.com - from this point on, the cache is hit at both URL
locations but I end up with 2X the DB hits and 2X over-the-wire web
service calls etc I really need.

This is turning out to be really really expensive. How can I avoid
this?

Any ideas?

On Fri, 14 Sep 2007, raghus wrote:

I am using fragment caching - the cache gets stored under RAILS_ROOT/
tmp/cache/www.mysite.com but if someone goes to http://mysite.com (no
www) then, a second cache gets stored at RAILS_ROOT/tmp/cache/
mysite.com - from this point on, the cache is hit at both URL
locations but I end up with 2X the DB hits and 2X over-the-wire web
service calls etc I really need.

This is turning out to be really really expensive. How can I avoid
this?

You can ensure they always visit the non-www version of your domain
name. Here’s an Apache rewrite rule for that:

RewriteCond %{HTTP_HOST} !^mysite.com$ [NC]
RewriteRule ^(.*) http://mysite.com/$1 [L,R=301]


Greg D.
Cyberfusion Consulting
http://cyberfusionconsulting.com/

Any ideas?
Not a solution to your problem directly, but you may want to consider
301
redirecting all requests to mysite.com to www.mysite.com.

I know that Google will punish your page rankings if it sees the same
content in multiple domains…

As a side effect it would also solve your problem…

-philip

That’s an idea that would have the side-effect of solving my problem
yes, but I don’t believe Google will punish PR between www and a plain
site.com. As you say multiple domains: perhaps between alpha.com and
beta.com if there’s exactly the same content, then… maybe.

Greg D. wrote:

You can ensure they always visit the non-www version of your domain
name. Here’s an Apache rewrite rule for that:

RewriteCond %{HTTP_HOST} !^mysite.com$ [NC]
RewriteRule ^(.*) http://mysite.com/$1 [L,R=301]

Beware. If you have multiple sites running under the same domain this
will lead to trouble with cookies and IE. That is if you have both
example.com and anotherapp.example.com.


Cheers,

  • Jacob A.

You may be right… now that I think about it our problem was the
individual hostnames vs www.

It definitely punished us for that.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs