action caching, sweeping and subdomains

0 views
Skip to first unread message

matt

unread,
Jul 15, 2008, 8:22:10 PM7/15/08
to Ruby Ireland
Quick question for an edge case - just checking if anyone's come up
against it before......
If you're doing action caching and using something like this to expire
a cached fragment;

expire_fragment(:controller => '/news', :action =>
'find_by_date', :year => post.publish_date.year)

it works fine, BUT lets say you have the following urls that can be
used on both the front and back end;

http://www.beyondendurance.ie
AND
http://beyondendurance.ie (without the www)

this will give TWO caching folder structures in the cache path

www.beyondendurance.ie/views/news/2008/whatever
and
beyondendurance.ie/views/news/2008/whatever

NOW, the problem is if someone is in your admin and fires a sweeper to
set off;
expire_fragment(:controller => '/news', :action =>
'find_by_date', :year => post.publish_date.year)

It will only clear the cache under whichever domain they are operating
in.

Possible solutions;
* use regex (maybe bad? - http://gurge.com/blog/2007/02/04/rails-expire_fragmentregex-considered-harmful/)
* clear everything from the cache directories (i'd rather not)
* force non - www. domain to always redirect to www.beyondendurance.ie
* have a cup of tea and forget about it?

Any suggestions, ideas?

m



Dave Rice

unread,
Jul 15, 2008, 8:32:19 PM7/15/08
to ruby_i...@googlegroups.com
Matt, yeah the best way (imho) is to ensure canonical urls for everything (which is good for google fu too) by using rewrite rules.

I'm guessing you're on nginx? :)

server {
    rewrite ^(.*) http://domain.com$1 permanent;
    ...
}

Best,
Dave



---
David Rice
+44 (0)78 708 12996




matt

unread,
Jul 16, 2008, 4:46:22 AM7/16/08
to Ruby Ireland
You've guess correctly, i'll give that a go

thanks!

m

On Jul 16, 1:32 am, Dave Rice <davidjr...@gmail.com> wrote:
> Matt, yeah the best way (imho) is to ensure canonical urls for  
> everything (which is good for google fu too) by using rewrite rules.
>
> I'm guessing you're on nginx? :)
>
> server {
>      rewrite ^(.*)http://domain.com$1permanent;
>      ...
>
> }
>
> Best,
> Dave
>
> On 16 Jul 2008, at 01:22, matt wrote:
>
>
>
>
>
> > Quick question for an edge case - just checking if anyone's come up
> > against it before......
> > If you're doing action caching and using something like this to expire
> > a cached fragment;
>
> > expire_fragment(:controller => '/news', :action =>
> > 'find_by_date', :year => post.publish_date.year)
>
> > it works fine, BUT lets say you have the following urls that can be
> > used on both the front and back end;
>
> >http://www.beyondendurance.ie
> > AND
> >http://beyondendurance.ie(without the www)
>
> > this will give TWO caching folder structures in the cache path
>
> >www.beyondendurance.ie/views/news/2008/whatever
> > and
> > beyondendurance.ie/views/news/2008/whatever
>
> > NOW, the problem is if someone is in your admin and fires a sweeper to
> > set off;
> > expire_fragment(:controller => '/news', :action =>
> > 'find_by_date', :year => post.publish_date.year)
>
> > It will only clear the cache under whichever domain they are operating
> > in.
>
> > Possible solutions;
> > * use regex (maybe bad? -http://gurge.com/blog/2007/02/04/rails-expire_fragmentregex-considere...)

macarthy

unread,
Jul 17, 2008, 11:45:37 AM7/17/08
to Ruby Ireland
Great to rails is used on Pats site. If only I had a spare 10K to go
with him :-)

Justin

On Jul 16, 9:46 am, matt <m...@hiddenloop.com> wrote:
> You've guess correctly, i'll give that a go
>
> thanks!
>
> m
>
> On Jul 16, 1:32 am, Dave Rice <davidjr...@gmail.com> wrote:
>
> > Matt, yeah the best way (imho) is to ensure canonical urls for  
> > everything (which is good for google fu too) by using rewrite rules.
>
> > I'm guessing you're on nginx? :)
>
> > server {
> >      rewrite ^(.*)http://domain.com$1permanent;
> >      ...
>
> > }
>
> > Best,
> > Dave
>
> > On 16 Jul 2008, at 01:22, matt wrote:
>
> > > Quick question for an edge case - just checking if anyone's come up
> > > against it before......
> > > If you're doing action caching and using something like this to expire
> > > a cached fragment;
>
> > > expire_fragment(:controller => '/news', :action =>
> > > 'find_by_date', :year => post.publish_date.year)
>
> > > it works fine, BUT lets say you have the following urls that can be
> > > used on both the front and back end;
>
> > >http://www.beyondendurance.ie
> > > AND
> > >http://beyondendurance.ie(withoutthe www)
Reply all
Reply to author
Forward
0 new messages