我在 /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
谢谢!