librelist archives

« back to archive

Caching breaks home page

Caching breaks home page

From:
Kevin Zurawel
Date:
2012-01-20 @ 19:39
Hello,

I recently set up basic caching for my site by adding rack-cache in my 
config.ru and setting up the following "before" call in my theme's app.rb:

before do
  if request.path =~ Regexp.new('./$')
    redirect to(request.path.sub(Regexp.new('/$'), ''))
  end
  expires 900, :public
end

I just copied the default before call and added a call to the expires helper.

For 99% of my site, it works great - initial page load takes the normal 
time, and subsequent page loads (within 15 minutes) take a fraction of a 
second. The problem is that any attempt to load my home page ("/") results
in the following:

File not found: index.html

Now I'm not really sure why I'm getting this. I have an index.haml in my 
/content/pages directory. I tried adding a route specifically for the home
page:

get '/' do
  set_common_variables
  haml(:index)
end

…and then copied my index.haml into my theme's views folder, but that 
didn't work either. Could this possibly be related to Jonathan's issue 
here: 
http://librelist.com/browser//nesta/2012/1/17/theme-issue/#5bf6e9b425681b70a5087c8e45e40809
??

Thanks in advance for your help!
Kevin Zurawel

Re: [nesta] Caching breaks home page

From:
Jonathan Ballinger
Date:
2012-01-20 @ 19:45
I'm not yet experienced enough to say whether it's the same as my
issue or not.  I didn't do anything explicitly related to caching but
updating my rails related gems and reinstalling has done nothing to
fix my issue.

Maybe there's a similarity in our environments that could account for
it?  When I'm next at my machine I'll see about getting a list of
pertinent version numbers.

On 20 January 2012 19:39, Kevin Zurawel <kzurawel@gmail.com> wrote:
> Hello,
>
> I recently set up basic caching for my site by adding rack-cache in my
> config.ru and setting up the following "before" call in my theme's app.rb:
>
> before do
>   if request.path =~ Regexp.new('./$')
>     redirect to(request.path.sub(Regexp.new('/$'), ''))
>   end
>   expires 900, :public
> end
>
> I just copied the default before call and added a call to the expires
> helper.
>
> For 99% of my site, it works great - initial page load takes the normal
> time, and subsequent page loads (within 15 minutes) take a fraction of a
> second. The problem is that any attempt to load my home page ("/") results
> in the following:
>
> File not found: index.html
>
>
> Now I'm not really sure why I'm getting this. I have an index.haml in my
> /content/pages directory. I tried adding a route specifically for the home
> page:
>
> get '/' do
>   set_common_variables
>   haml(:index)
> end
>
> …and then copied my index.haml into my theme's views folder, but that didn't
> work either. Could this possibly be related to Jonathan's issue
> 
here: http://librelist.com/browser//nesta/2012/1/17/theme-issue/#5bf6e9b425681b70a5087c8e45e40809
> ??
>
> Thanks in advance for your help!
> Kevin Zurawel

Re: [nesta] Caching breaks home page

From:
Kevin Zurawel
Date:
2012-01-20 @ 20:12
Thanks Jonathan.

I found that visiting /index would load the index.haml from my 
content/pages directory. I tried changing my route to this:

get "/" do
  redirect '/index'
end

But I still get the Rack "File not found" message.



On Jan 20, 2012, at 2:45 PM, Jonathan Ballinger wrote:

> I'm not yet experienced enough to say whether it's the same as my
> issue or not.  I didn't do anything explicitly related to caching but
> updating my rails related gems and reinstalling has done nothing to
> fix my issue.
> 
> Maybe there's a similarity in our environments that could account for
> it?  When I'm next at my machine I'll see about getting a list of
> pertinent version numbers.
> 
> On 20 January 2012 19:39, Kevin Zurawel <kzurawel@gmail.com> wrote:
>> Hello,
>> 
>> I recently set up basic caching for my site by adding rack-cache in my
>> config.ru and setting up the following "before" call in my theme's app.rb:
>> 
>> before do
>>   if request.path =~ Regexp.new('./$')
>>     redirect to(request.path.sub(Regexp.new('/$'), ''))
>>   end
>>   expires 900, :public
>> end
>> 
>> I just copied the default before call and added a call to the expires
>> helper.
>> 
>> For 99% of my site, it works great - initial page load takes the normal
>> time, and subsequent page loads (within 15 minutes) take a fraction of a
>> second. The problem is that any attempt to load my home page ("/") results
>> in the following:
>> 
>> File not found: index.html
>> 
>> 
>> Now I'm not really sure why I'm getting this. I have an index.haml in my
>> /content/pages directory. I tried adding a route specifically for the home
>> page:
>> 
>> get '/' do
>>   set_common_variables
>>   haml(:index)
>> end
>> 
>> …and then copied my index.haml into my theme's views folder, but that didn't
>> work either. Could this possibly be related to Jonathan's issue
>> here: 
http://librelist.com/browser//nesta/2012/1/17/theme-issue/#5bf6e9b425681b70a5087c8e45e40809
>> ??
>> 
>> Thanks in advance for your help!
>> Kevin Zurawel

Re: [nesta] Caching breaks home page

From:
Kevin Zurawel
Date:
2012-01-20 @ 21:51
For anyone else having this problem, it's a Rack issue:

https://github.com/rack/rack/commit/5ab871f2a86ca4f943a5b1d0a3d0f32a2f9f77ef

When :index is not specified, Rack defaults to looking for index.html, 
which breaks. Change that one line in your rack gem and it works.

Kevin


On Jan 20, 2012, at 2:45 PM, Jonathan Ballinger wrote:

> I'm not yet experienced enough to say whether it's the same as my
> issue or not.  I didn't do anything explicitly related to caching but
> updating my rails related gems and reinstalling has done nothing to
> fix my issue.
> 
> Maybe there's a similarity in our environments that could account for
> it?  When I'm next at my machine I'll see about getting a list of
> pertinent version numbers.
> 
> On 20 January 2012 19:39, Kevin Zurawel <kzurawel@gmail.com> wrote:
>> Hello,
>> 
>> I recently set up basic caching for my site by adding rack-cache in my
>> config.ru and setting up the following "before" call in my theme's app.rb:
>> 
>> before do
>>   if request.path =~ Regexp.new('./$')
>>     redirect to(request.path.sub(Regexp.new('/$'), ''))
>>   end
>>   expires 900, :public
>> end
>> 
>> I just copied the default before call and added a call to the expires
>> helper.
>> 
>> For 99% of my site, it works great - initial page load takes the normal
>> time, and subsequent page loads (within 15 minutes) take a fraction of a
>> second. The problem is that any attempt to load my home page ("/") results
>> in the following:
>> 
>> File not found: index.html
>> 
>> 
>> Now I'm not really sure why I'm getting this. I have an index.haml in my
>> /content/pages directory. I tried adding a route specifically for the home
>> page:
>> 
>> get '/' do
>>   set_common_variables
>>   haml(:index)
>> end
>> 
>> …and then copied my index.haml into my theme's views folder, but that didn't
>> work either. Could this possibly be related to Jonathan's issue
>> here: 
http://librelist.com/browser//nesta/2012/1/17/theme-issue/#5bf6e9b425681b70a5087c8e45e40809
>> ??
>> 
>> Thanks in advance for your help!
>> Kevin Zurawel

Re: [nesta] Caching breaks home page

From:
Jonathan Ballinger
Date:
2012-01-20 @ 22:07
I can confirm this is the same issue for me. Thanks for posting that, Kevin.


--  
Jonathan Ballinger
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Friday, 20 January 2012 at 21:51, Kevin Zurawel wrote:

> For anyone else having this problem, it's a Rack issue:
>  
> https://github.com/rack/rack/commit/5ab871f2a86ca4f943a5b1d0a3d0f32a2f9f77ef
>  
> When :index is not specified, Rack defaults to looking for index.html, 
which breaks. Change that one line in your rack gem and it works.
>  
> Kevin
>  
>  
> On Jan 20, 2012, at 2:45 PM, Jonathan Ballinger wrote:
>  
> > I'm not yet experienced enough to say whether it's the same as my
> > issue or not. I didn't do anything explicitly related to caching but
> > updating my rails related gems and reinstalling has done nothing to
> > fix my issue.
> >  
> > Maybe there's a similarity in our environments that could account for
> > it? When I'm next at my machine I'll see about getting a list of
> > pertinent version numbers.
> >  
> > On 20 January 2012 19:39, Kevin Zurawel <kzurawel@gmail.com 
(mailto:kzurawel@gmail.com)> wrote:
> > > Hello,
> > >  
> > > I recently set up basic caching for my site by adding rack-cache in my
> > > config.ru (http://config.ru) and setting up the following "before" 
call in my theme's app.rb:
> > >  
> > > before do
> > > if request.path =~ Regexp.new('./$')
> > > redirect to(request.path.sub(Regexp.new('/$'), ''))
> > > end
> > > expires 900, :public
> > > end
> > >  
> > > I just copied the default before call and added a call to the expires
> > > helper.
> > >  
> > > For 99% of my site, it works great - initial page load takes the normal
> > > time, and subsequent page loads (within 15 minutes) take a fraction of a
> > > second. The problem is that any attempt to load my home page ("/") results
> > > in the following:
> > >  
> > > File not found: index.html
> > >  
> > >  
> > > Now I'm not really sure why I'm getting this. I have an index.haml in my
> > > /content/pages directory. I tried adding a route specifically for the home
> > > page:
> > >  
> > > get '/' do
> > > set_common_variables
> > > haml(:index)
> > > end
> > >  
> > > …and then copied my index.haml into my theme's views folder, but that didn't
> > > work either. Could this possibly be related to Jonathan's issue
> > > here: 
http://librelist.com/browser//nesta/2012/1/17/theme-issue/#5bf6e9b425681b70a5087c8e45e40809
> > > ??
> > >  
> > > Thanks in advance for your help!
> > > Kevin Zurawel
> >  
>