Timed_fragment_cache always expires

I have downloaded the latest version of the plugin timed_fragment_cache.
Which makes timed cache expiration possible in the filesystem.

My first experiment was this:

In my controller I have the following code:

when_fragment_expired(‘front_popular_races’, 10.minutes.ago) do
@popular_races = Race.popular
end

And in the view:

<% cache(‘front_popular_races’) do %>
<% for race in @popular_races %>
<%= link_to race.name, ‘/racehunde/’ + CGI::escape(race.name),
:class => ‘race’ %>


<% end %>
<% end %>

But the cached fragment file expires and gets regenerated on every
request. What am I doing wrong?

  • Carsten

Are you running in development mode? Did you set:

config.action_controller.perform_caching = true

in environments/development.rb

Cheers,

Nick.

Carsten G. wrote:

I have downloaded the latest version of the plugin timed_fragment_cache.
Which makes timed cache expiration possible in the filesystem.

My first experiment was this:

In my controller I have the following code:

when_fragment_expired(‘front_popular_races’, 10.minutes.ago) do
@popular_races = Race.popular
end

And in the view:

<% cache(‘front_popular_races’) do %>
<% for race in @popular_races %>
<%= link_to race.name, ‘/racehunde/’ + CGI::escape(race.name),
:class => ‘race’ %>


<% end %>
<% end %>

But the cached fragment file expires and gets regenerated on every
request. What am I doing wrong?

  • Carsten

Nick A. wrote:

Are you running in development mode? Did you set:

config.action_controller.perform_caching = true

in environments/development.rb

I was yes - this was an old question, but thanks for answering anyway
:slight_smile:

  • Carsten

Hi,

I am facing the same problem using timed_fragment_cache plugin.
And do all the steps i need to do.
it works fine for time being cache.
But for the left all it not work it expires.

Any Idea?

Arun A.

Carsten G. wrote:

Nick A. wrote:

Are you running in development mode? Did you set:

config.action_controller.perform_caching = true

in environments/development.rb

I was yes - this was an old question, but thanks for answering anyway
:slight_smile:

  • Carsten

Arun A. wrote:

Hi,

I am facing the same problem using timed_fragment_cache plugin.
And do all the steps i need to do.
it works fine for time being cache.
But for the left all it not work it expires.

I ended up choosing another approach. I am using the normal cache
system. Then I made a cronjob, that deletes the cache files after after
a certain amount of time.

  • Carsten

On May 31, 4:32 pm, Carsten G. [email protected]
wrote:

a certain amount of time.

  • Carsten

    Posted viahttp://www.ruby-forum.com/.

Carsten, Just out of curiosity, Was that because of a limitation in
the plugin or you just wanted a cron based solution?
Are you using capistrano to setup that cron job? Cos otherwise it
seems like another bit to configure unless of course the plugin didnt
meet your requirements.

Cheers,
Aditya

Just a question on the original code.

Shouldn’t the line
when_fragment_expired(‘front_popular_races’, 10.minutes.ago) do

be
when_fragment_expired(‘front_popular_races’, 10.minutes.from_now) do

?

Perhaps that’s the reason why the cache always expires.

Aditya wrote:

Carsten, Just out of curiosity, Was that because of a limitation in
the plugin or you just wanted a cron based solution?
Are you using capistrano to setup that cron job? Cos otherwise it
seems like another bit to configure unless of course the plugin didnt
meet your requirements.

Oh it was simply, that I never succeded in getting the fragments to
time-out and be rebuilt. After using 2 days on it, I had to quickly find
another solution.

Our site was suddenly having a LOT of requests due to a TV commercial so
I just had to get some cache to work quickly.

  • Carsten

Sean T. wrote:

Just a question on the original code.

Shouldn’t the line
when_fragment_expired(‘front_popular_races’, 10.minutes.ago) do

be
when_fragment_expired(‘front_popular_races’, 10.minutes.from_now) do

?

Perhaps that’s the reason why the cache always expires.

Possibly. It’s been so long since I tried it. But I think, that I tested
both cases, because I was in doubt myself.

Anyway it’s so long ago. :slight_smile:

  • Carsten