ruby-on-rails – HTML5应用程序清单不清除清单更改上的缓存

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – HTML5应用程序清单不清除清单更改上的缓存前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个rails应用程序,我试图使用Rack :: Offline使用 HTML5应用程序缓存. application.manifest文件已设置,正在由我的HTML页面下载和检查.
清单如下:
  1. CACHE MANIFEST
  2. # 2d9bf2b03a07dc960fd8fe69659ceeffd4d28ccf8619669a506c3682bf223878
  3. 404.html
  4. 422.html
  5. 500.html
  6. login.html
  7. stylesheets/scaffold.css
  8. javascripts/jquery.min.js
  9. javascripts/jquery.js
  10. javascripts/application.js
  11. javascripts/rmbz.js
  12. javascripts/rails.js
  13. images/rails.png
  14.  
  15. NETWORK:
  16. /

我正在访问的页面是localhost:3000 / mobile,它已经缓存得很好(当我取下rails服务器时可以查看).但是,它引用的application.manifest文件已更改(实际上它通过操作注释的十六进制ID随每个请求而更改),但Chrome不更新页面. Chrome中的控制台日志提供以下内容

  1. Document was loaded from Application Cache with manifest http://localhost:3000/application.manifest
  2. Application Cache Checking event
  3. Application Cache Downloading event
  4. Application Cache Progress event (0 of 12) http://localhost:3000/login.html
  5. Application Cache Progress event (1 of 12) http://localhost:3000/404.html
  6. Application Cache Progress event (2 of 12) http://localhost:3000/422.html
  7. Application Cache Progress event (3 of 12) http://localhost:3000/javascripts/rails.js
  8. Application Cache Progress event (4 of 12) http://localhost:3000/javascripts/rmbz.js
  9. Application Cache Progress event (5 of 12) http://localhost:3000/images/rails.png
  10. Application Cache Progress event (6 of 12) http://localhost:3000/500.html
  11. Application Cache Progress event (7 of 12) http://localhost:3000/javascripts/jquery.js
  12. Application Cache Progress event (8 of 12) http://localhost:3000/stylesheets/scaffold.css
  13. Application Cache Progress event (9 of 12) http://localhost:3000/javascripts/jquery.min.js
  14. Application Cache Progress event (10 of 12) http://localhost:3000/mobile
  15. Application Cache Progress event (11 of 12) http://localhost:3000/javascripts/application.js
  16. Application Cache Error event: Manifest changed during update,scheduling retry

我不太明白为什么会失败.它似乎在做到最后一行之前应该做的一切!如果我在浏览器中导航到localhost:3000 / application.manifest,我会得到一个类似的日志 – 似乎清单本身就被缓存了,那么这就是为什么它会抱怨清单已经改变了?有任何想法吗?

谢谢!

解决方法

我遇到了同样的问题,不得不改变宝石本身.我的问题与/ public / images中的嵌套文件夹有关

首先找到你的宝石安装位置(“宝石环境”会告诉你)并导航到/rack-offline-0.6.1/lib.

编辑文件rack-offline.rb.删除第33行并替换为:

  1. "#{root}/images/**/*.png","#{root}/images/**/*.jpg","#{root}/images/**/*.gif"]

重新启动rails服务器,然后重试.为我工作,希望它能帮到你.

猜你在找的Ruby相关文章