【问题标题】:Browser fails to cache page assets for Rails 4 Site浏览器无法缓存 Rails 4 站点的页面资源
【发布时间】:2015-10-04 13:31:31
【问题描述】:

在访问我们的 Rails 4 网站时,我们使用 Chrome 开发人员工具来查看我们的网络性能并监控各种资产的页面加载速度。这表明很少有资产被/正在被缓存。

诸如 application-.js 和 appliation-.css 文件,我们确信它们在页面加载之间没有改变,也没有被缓存。

在我们的 config/environments/production.rb 文件中,我们配置了以下内容:

    # Code is not reloaded between requests.
    config.cache_classes = true

    # Eager load code on boot. This eager loads most of Rails and
    # your application in memory, allowing both thread web servers
    # and those relying on copy on write to perform better.
    # Rake tasks automatically ignore this option for performance.
    config.eager_load = true

    # Full error reports are disabled and caching is turned on.
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true

    # Disable Rails's static asset server (Apache or nginx will already do this).
    config.serve_static_files = false

    # Compress JavaScripts and CSS.
    config.assets.js_compressor = :uglifier
    config.assets.css_compressor = :sass

    # Do not fallback to assets pipeline if a precompiled asset is missed.
    config.assets.compile = false

    # Generate digests for assets URLs.
    config.assets.digest = true

    # Version of your assets, change this if you want to expire all your assets.
    config.assets.version = '1.0'

    # Set to :debug to see everything in the log.
    config.log_level = :info

    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
    # the I18n.default_locale when a translation can not be found).
    config.i18n.fallbacks = true

    # Send deprecation notices to registered listeners.
    config.active_support.deprecation = :notify

    # Use default logging formatter so that PID and timestamp are not suppressed.
    config.log_formatter = ::Logger::Formatter.new

对为什么会发生这种情况有任何想法吗?谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby apache caching browser-cache


    【解决方案1】:

    这原来是我正在测试的浏览器设置的问题。退出并重新启动浏览器,静态元素再次按预期缓存。

    【讨论】:

      猜你喜欢
      • 2012-03-04
      • 1970-01-01
      • 2022-01-15
      • 2010-10-17
      • 2015-01-16
      • 1970-01-01
      • 2019-01-18
      • 1970-01-01
      • 2014-05-26
      相关资源
      最近更新 更多