Rails page cache expires automatically after a certain amount of time

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


source to share

2 answers

Set up a cron job to remove it:

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


If you use every time this should do the trick:

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


If you want to recover the file, add the following immediately:

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




If you just need to restore the page every couple of days, whenever should do the job.



All Articles