2

根据Ruby on Rails 指南:缓存,在开发和测试环境中默认禁用缓存。如果我做一个小的 CSS 更改,运行rails server并访问我的网站localhost:3000,我可以看到我的更改。但是,如果我在 iPhone 上访问我的 rails 服务器10.0.1.2:3000,CSS 不会更新,即使 Chrome 处于隐身模式。当我尝试其他具有空缓存的 iPhone 时,变化就在那里。

我发现了一个描述相同问题的堆栈溢出帖子。以下是建议的解决方案:

  • 删除public/assets目录。我没有。
  • 添加config.serve_static_assets = falseenvironments/development.rb. 它已经在那里了。
  • 删除/tmp/cache/assets、添加并config.serve_static_assets = false重新environments/development.rb启动服务器。我试过了,但没有用。

这是我的相关environments/development.rb配置:

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Show full error reports and disable caching
config.consider_all_requests_local       = true
config.action_controller.perform_caching = false
4

4 回答 4

5

我很确定这是因为 Rails 只在生产中进行指纹识别:http: //guides.rubyonrails.org/asset_pipeline.html#in-production

这意味着在开发中更具缓存攻击性的浏览器可能会遇到此问题。

尝试将此添加到您的 development.rb 中:

config.assets.digest = true

或者更可取的条件是您进行移动开发时的条件

# One of the few exceptions I'd make to a no ENV variables rule 
# for my rails environment config files
config.assets.digest = true if ENV["MOBILE_DEBUG"]
于 2013-01-13T23:44:52.477 回答
0

我没有要测试的 iPhone,但这听起来像是正常的浏览器缓存问题。尝试使用这些说明清除浏览器缓存。如果可行,则每次更新 CSS(或 J

于 2013-01-08T17:13:31.370 回答
0

如何通过你的 iphone 访问你的本地机器?

您是否配置了任何网络设置,或者您将其推送到另一台服务器并从那里访问,因为如果您将其推送到另一台服务器,则该服务器可能正在生产模式下运行。

高温高压

于 2013-01-06T07:05:31.550 回答
0

我有一个类似的问题。它的发生是因为我config/environments/development.rb已经包含config.asset_host = 'http://localhost:3000'

我已将其删除,一切正常。

于 2015-11-18T13:16:42.243 回答