Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 请求带有cron的页面以更新缓存_Ruby On Rails_Heroku - Fatal编程技术网

Ruby on rails 请求带有cron的页面以更新缓存

Ruby on rails 请求带有cron的页面以更新缓存,ruby-on-rails,heroku,Ruby On Rails,Heroku,我在Heroku上使用http缓存: def homepage response.headers['Cache-Control'] = 'public, max-age=86340' ... end 我还添加了Heroku的免费cron插件: desc "This task is called by the Heroku cron add-on" task :cron => :environment do if Time.now.hour == 0 # run at midni

我在Heroku上使用http缓存:

def homepage
  response.headers['Cache-Control'] = 'public, max-age=86340'
  ...
end
我还添加了Heroku的免费cron插件:

desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
 if Time.now.hour == 0 # run at midnight
   # I want to request a page here
 end
end
你能告诉我我应该在这个文件里放些什么来申请一个页面吗

一个类似的问题也被问到了 他们没有在答案中提供一个例子

require 'uri'
require 'net/http'

desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
 if Time.now.hour == 0 # run at midnight
   uri = URI.parse('http://my-app.heroku.com/page')
   Net::HTTP.get(uri)
 end
end
应该这样做