concept47
concept47

Reputation: 31736

Expiring a Rails Page cache automatically after a certain amount of time

I am generating a big sitemap for a site and using page caching on it, so that a sitemap.xml is generated in my public folder.
Is there a way to have this page expire after say 3.days? I've looked but couldn't find anything that could do that.

Upvotes: 2

Views: 1765

Answers (2)

Roger Ertesvag
Roger Ertesvag

Reputation: 1794

Set up a cron job to delete it:

cd /home/user/apps/myapp/current/public/ && rm sitemap.xml

If you use Whenever this should do the trick:

every 3.days, :at => '1:00am' do
  command "cd /home/user/apps/myapp/current/public/ && rm sitemap.xml"
end

If you want to regenerate the file immediately add the following:

&& curl http://www.example.com/sitemap.xml

Upvotes: 5

ez.
ez.

Reputation: 7654

If you just need to regenerate the page every couple days whenever should do the job.

Upvotes: 1

Related Questions