Rails: Scheduled task to warm up the cache?

前端 未结 4 809
暗喜
暗喜 2021-02-06 08:08

I am using the following to cache a slow loading page using memcached:

caches_action :complex_report, :expires_in => 1.day

The controller ac

4条回答
  •  青春惊慌失措
    2021-02-06 08:36

    Probably the most basic solution would be to set up a simple cron entry to load up the page you'll want to have a 'hot' cache. This can be as easy adding the following to the crontab of a user on your server using crontab -e to open an editor:

    */15 * * * * wget -q http://yourwebpages.url/ > /dev/null 2>&1

    What this will do is use wget to fetch the data at the provided url every 15 minutes of every hour, day, month and year, ignore the results and not send *nix mail in case something goes wrong.

提交回复
热议问题