Caching JavaScript, Rails and Apache Passenger?

I wrote a Capistrano recipe to delete a cached JavaScript file all.jsand told the server to restart, but it still does not work correctly. And inevitably, I have to manually delete the file all.js, and then manually restart Apache. (touching restart.txt does not always work).

Does anyone have a working solution to this problem?

Here is the current recipe:

desc "Package Javascripts"  
    task :package_javascripts, :roles => :web do
      sudo %{rm -f #{current_path}/public/javascripts/all.js}
      javascripts.each do |javascript|
        run %{/usr/bin/ruby #{current_path}/lib/jsmin.rb < \
              #{current_path}/public/javascripts/#{javascript}.js >> \
              #{current_path}/public/javascripts/all.js}
      end
      run "touch #{current_path}/tmp/restart.txt"
    end
+3
source share
1 answer

Have you helped somewhere:

after "deploy:symlink", :package_javascripts

Also change the restart line to:

run "rm -f #{current_path}/tmp/restart.txt ; touch #{current_path}/tmp/restart.txt"
0
source

Source: https://habr.com/ru/post/1742313/


All Articles