Search code examples
ruby-on-railsasset-pipeline

Why use Rails asset pipeline with images?


What's the benefit of putting images in the Rails asset pipeline (instead of just putting them in a public directory like public/img directly)?


Solution

  • Just like with CSS and JS files, Rails appends a hash of the file name and contents to the actual file name, so that when you update an image on your server it will also update in any browser and CDN cache, otherwise you'd have to do it manually or wait until it expires.