0

下面是相关的源代码:

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

生成的清单似乎很好,资产也是如此,但它会在 Chrome 上显示以下消息,随机停止下载/缓存资产:https://muster-apotheke.splettville.com/application.manifest

感谢任何帮助。

4

1 回答 1

2

通过使用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
于 2013-01-17T16:47:41.273 回答