我有一个rake任务,每分钟都要运行一次.
它登录后,会找到我感兴趣的JSON,但在rake任务中注意到JsON中的任何更改之前,最多可以执行30次任务.在此期间,我错过了某些JsON对象的几处更改.
好像有一些缓存正在进行,我试图关闭如图所示的Mechanize缓存,只是不确定我现在还能尝试什么.
有什么指针吗?
提前致谢.
agent = Mechanize.new # {|a| a.log = Logger.new(STDERR) } agent.history.clear agent.max_history = 0 agent.user_agent_alias = 'Mac Safari' page = agent.get 'http://website.com' form = page.forms.first form.email = 'me@home.com' form.password = 'mypassword' page = agent.submit form page = agent.get 'http://website.com/password_protected_page' JsonDirty = page.search '//script[@type="application/Json"]'
服务器响应:
{"server"=>"Nginx","date"=>"Thu,13 Sep 2012 14:16:43 GMT","content-type"=>"text/HTML; charset=utf-8","connection"=>"close","vary"=>"cookie","content-language"=>"plfplen","set-cookie"=>"csrftoken=pVDg2SJ4KHqONz2OIEkNK7IbKlnjsQQf; expires=Thu,12-Sep-2013 14:16:43 GMT; Max-Age=31449600; Path=/,affiliate=; expires=Thu,01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/,one-click-join=; expires=Thu,01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/","expires"=>"Thu,01 Jan 1970 00:00:01 GMT","cache-control"=>"no-cache","content-encoding"=>"gzip","transfer-encoding"=>"chunked"}解决方法 您可以尝试将随机查询参数附加到URL.如:
page = agent.get "http://website.com/password_protected_page?random=#{Time.Now.to_i}"总结
以上是内存溢出为你收集整理的ruby-on-rails – 刮耙任务似乎遭受了不必要的缓存全部内容,希望文章能够帮你解决ruby-on-rails – 刮耙任务似乎遭受了不必要的缓存所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)