【问题标题】:HTML5 Offline feature doesn't work on Heroku server though It runs perfectly on dev machineHTML5 离线功能在 Heroku 服务器上不起作用,尽管它在开发机器上完美运行
【发布时间】:2013-01-16 17:52:21
【问题描述】:
以下是相关源码:
offline = Rack::Offline.configure :cache_interval => 120 do
Rails.application.assets.each_logical_path.select{|e| not e.include? ".pdf"}.
each {|e| cache "assets/" + e}
network "/"
end
match "/application.manifest" => offline
生成的manifest 似乎很好,资产也是,但它会随机停止下载/缓存资产,并在 Chrome 上显示以下消息:https://muster-apotheke.splettville.com/application.manifest
感谢任何帮助。
【问题讨论】:
标签:
ruby-on-rails
html
heroku
asset-pipeline
offline-caching
【解决方案1】:
通过使用asset_path辅助方法,我可以在缓存清单中引用生产资产:
if Rails.env.production?
offline = Rack::Offline.configure :cache_interval => 120 do
cache ActionController::Base.helpers.asset_path("application.css")
cache ActionController::Base.helpers.asset_path("application.js")
network "/"
end
match "/application.manifest" => offline
else
offline = Rack::Offline.configure :cache_interval => 120 do
Rails.application.assets.each_logical_path.select{|e| not e.include? ".pdf"}.each {|e| cache "assets/" + e}
network "/"
end
match "/application.manifest" => offline
end