config.assets.compile=true in Rails production, why not?

前端 未结 7 1734
闹比i
闹比i 2020-11-22 07:17

The default Rails app installed by rails new has config.assets.compile = false in production.

And the ordinary way to do things is to run

相关标签:
7条回答
  • 2020-11-22 08:16

    From the official guide:

    On the first request the assets are compiled and cached as outlined in development above, and the manifest names used in the helpers are altered to include the MD5 hash.

    Sprockets also sets the Cache-Control HTTP header to max-age=31536000. This signals all caches between your server and the client browser that this content (the file served) can be cached for 1 year. The effect of this is to reduce the number of requests for this asset from your server; the asset has a good chance of being in the local browser cache or some intermediate cache.

    This mode uses more memory, performs poorer than the default and is not recommended.

    Also, precompile step is not trouble at all if you use Capistrano for your deploys. It takes care of it for you. You just run

    cap deploy
    

    or (depending on your setup)

    cap production deploy
    

    and you're all set. If you still don't use it, I highly recommend checking it out.

    0 讨论(0)
提交回复
热议问题