Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating assets without restarting rails server

So the question basically boild down to this:

How do you efficiently handle changing assets in a production rails environment without the need to restart the server?

The problem we're experiencing is, we have to restart the Thin server that runs the app in order for the updated javascript files to be served.

Some background:

Right now we're generating data from a couple of long running tasks into javascript files once an hour so we can use it in our Rails app.
To be clear, we update/overwrite existing files, not adding new ones.

After generation we run these commands in order to re-precompile all the assets.

bundle exec rake assets:precompile
bundle exec rake rails_group=assets assets:clean RAILS_ENV=production

Still after clearing the browser cache and reloading the page we're being served the old assets.

Have you guys made any similar experiences; what did you do to work around it?

PS. Happy holidays to you all!

like image 951
deRailed Avatar asked Nov 03 '22 08:11

deRailed


1 Answers

So, what we ended up doing is basically letting rails also serve static assets by setting

config.serve_static_assets = true in config/environments/production.rb

and just putting the frequently changing javascript data files into a directory structure under public/. This works grate since it also separates assets and data into different locations.

like image 135
deRailed Avatar answered Nov 10 '22 05:11

deRailed