【问题标题】:Rails config.static_cache_control how to exclude files from cacheRails config.static_cache_control 如何从缓存中排除文件
【发布时间】:2013-04-15 19:31:21
【问题描述】:

我正在为我的所有资产设置长期过期标头。但是,我的公共目录中有一些静态 HTML 文件(用于 Jekyll 博客),它们正在被缓存,并且在更新时没有为它们设置缓存破坏。实际上,它似乎只是我位于app/public/blog 的主要index.html 文件,它一直在缓存中。

是否像更改配置中的“public”一样简单?

config.static_cache_control = "public, max-age=604800"

【问题讨论】:

    标签: ruby-on-rails caching asset-pipeline


    【解决方案1】:

    我知道这是一个老问题,但我一直在寻找它,当我查找时(我一直在查找),所以这是答案:

    不,config.static_cache_control 中的 public 不引用 rails public/ 目录。

    事实上,在提供静态资产(包括 assets/ 中的 public/ 和 sprockets 编译的资产)时,整个字符串是用作 Cache-Control 标头的文字。

    有关如何在 rails 中使用 config.static_cache_control 的详细信息请参阅http://guides.rubyonrails.org/asset_pipeline.html#cdns-and-the-cache-control-header,有关 Cache-Control 标头含义的 w3c 文档请参阅http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-18
      • 1970-01-01
      • 2021-08-14
      • 2014-07-25
      • 2016-01-18
      • 2020-10-02
      相关资源
      最近更新 更多