So we should configure to cache page caches, action caches and fragment caches, and not to cache assets at all. Referring these two sites(1 2), we can do it by editing config/environments/production.rb like below:
# Prevent caching assets
config.middleware.insert_before Rack::Cache, ::ActionDispatch::Static, 'public', config.static_cache_control
Before launch the web serverIf you use Apache or nginx as your web server, you should modify the value of config.action_dispatch.x_sendfile_header on config/environments/production.rb. Then, if you use another web servers like WEBRick, you should modify to config.serve_static_assets = true on config/environments/production.rb.
If you plan to launch the web server on Windows, set config.assets.compress = false on config/environments/production.rb.
At last, precompile assets like below:
> rake assets:precompileAnd then, if you launch the server on development mode with precompiled assets, you should modify to config.serve_static_assets = false on config/environments/development.rb.