我的一些资产只是在Rails开发环境中缓存浏览器

时间:2022-02-25 23:33:43

I'm running rails 3.2. I'm trying to get page refreshes to be as fast as possible in development mode, so I've set the following config for my assets:

我正在运行rails 3.2。我正在尝试在开发模式下尽快让页面刷新,所以我为我的资产设置了以下配置:

  config.static_cache_control = "public, max-age=3600"
  config.assets.debug = false
  config.assets.digest = true

The idea is to have all assets served with a digest and be browser-cached. What I'm seeing is that only some of my assets are cached properly:

我们的想法是让所有资产都使用摘要并进行浏览器缓存。我所看到的是,我的一些资产只能正确缓存:

cache: [GET /assets/homepage/post-f7a1b20c625428032e3acf51388c8a6c.png] fresh
cache: [GET /assets/general/posted_check-0cf4eac99c06719e1ddf56a091550e80.png] fresh
cache: [GET /assets/general/about_footer.png] stale, valid, store
cache: [GET /assets/general/social_footer.png] stale, valid, store

The last two are getting Cache-Control:no-cache back from the server and I can't figure out why. Any ideas?

最后两个是获取缓存控制:从服务器返回无缓存,我无法弄清楚原因。有任何想法吗?

1 个解决方案

#1


1  

After setting config.assets.digest = true I have to clear the Sprockets asset cache. Deleting tmp/cache/assets fixed it.

设置config.assets.digest = true后,我必须清除Sprockets资产缓存。删除tmp / cache / assets修复了它。

#1


1  

After setting config.assets.digest = true I have to clear the Sprockets asset cache. Deleting tmp/cache/assets fixed it.

设置config.assets.digest = true后,我必须清除Sprockets资产缓存。删除tmp / cache / assets修复了它。