【问题标题】:Heroku Rails: Invalidate cache for /public/*.html on deploy?Heroku Rails:部署时 /public/*.html 的缓存无效?
【发布时间】:2013-10-26 11:35:55
【问题描述】:

我在 /public 中有一些原始 .html 文件,在我编辑和部署它们后仍在缓存中。目标是不必要求客户端在文件更改时(经常)清除其缓存。

我的 production.rb 包含这个:

# Use a different cache store in production
# pks: recommended by heroku
config.cache_store = :dalli_store

# For Rack::Cache on heroku
# Modify your config/environments/production.rb environment file to specify
# the appropriate storage backends for Rails’ built-in Rack::Cache integration.
config.action_dispatch.rack_cache = {
    :metastore    => Dalli::Client.new,
    :entitystore  => 'file:tmp/cache/rack/body',
    :allow_reload => false
}
# To allow your application to properly serve, invalidate and refresh static assets 
config.serve_static_assets = true
config.static_cache_control = "public, max-age=0" # 2592000" # max-age=0 to to force revalidate
config.assets.digest = true
config.action_controller.perform_caching = true    

谢谢!

【问题讨论】:

    标签: ruby-on-rails caching heroku static http-headers


    【解决方案1】:

    我认为您可以创建一个脚本,在您想要部署时运行该脚本,该脚本调用您用于部署的任何命令,然后使用以下帖子 (How can I clear rails cache after deploy to heroku?) 中列出的命令

    【讨论】:

      猜你喜欢
      • 2018-06-04
      • 2013-07-04
      • 2012-08-15
      • 2017-02-02
      • 1970-01-01
      • 2021-10-29
      • 1970-01-01
      • 1970-01-01
      • 2018-11-29
      相关资源
      最近更新 更多