加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails heroku应用程序上的Robots.txt文件未更

发布时间:2020-12-17 03:41:03 所属栏目:百科 来源:网络整理
导读:我有一个在Heroku上托管的rails应用程序,我正在尝试更新robot.txt文件. 本地文件位于/public/robots.txt,读取: User-agent: *Disallow: /admin/ 但是,当我将应用程序部署到Heroku时,机器人文件似乎没有更新.远程版本为: # See http://www.robotstxt.org/wc
我有一个在Heroku上托管的rails应用程序,我正在尝试更新robot.txt文件.

本地文件位于/public/robots.txt,读取:

User-agent: *
Disallow: /admin/

但是,当我将应用程序部署到Heroku时,机器人文件似乎没有更新.远程版本为:

# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the     robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
User-agent: *
Disallow: /

实时网址是http://www.cowboypicks.com/robots.txt.

运行curl -I http://www.cowboypicks.com/robots.txt产生:

HTTP/1.1 200 OK
Age: 2317078
Cache-Control: public,max-age=2592000
Content-length: 200
Content-Type: text/plain
Date: Wed,30 Apr 2014 17:01:43 GMT
Last-Modified: Thu,03 Apr 2014 14:21:08 GMT
Status: 200 OK
X-Content-Digest: 10c5b29b9aa0c6be63a410671662a29a796bc772
X-Rack-Cache: fresh
Connection: keep-alive

表明该文件自4月3日起尚未更新,但今天(4月30日)已更新.更奇怪的是,当我运行heroku运行bash后跟cat public / robots.txt我得到:

User-agent: *
Disallow: /admin/

指示文件正在Heroku上更新,但由于某种原因它显示较旧的(我假设缓存)版本.使用dalli / memcache在应用程序上有一些缓存,但我不认为会影响静态文件?关于如何进一步调试问题的任何想法?

解决方法

事实证明,Dalli确实在生产中缓存了robots.txt文件.到期日期在production.rb中设置了以下行:

config.static_cache_control = "public,max-age=2592000"

从rails控制台运行以下内容会刷新缓存并对问题进行排序:

Rails.cache.dalli.flush_all

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读