New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache public/assets if rake assets:clean_expired is available #44
Conversation
@@ -43,6 +43,9 @@ def run_assets_precompile_rake_task | |||
if File.exists?("public/assets/manifest.yml") | |||
puts "Detected manifest.yml, assuming assets were compiled locally" | |||
else | |||
FileUtils.mkdir_p('public') | |||
cache_load "public/assets" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this doesn't need to be conditional - It will just do nothing if 'public/assets' isn't cached.
|
||
# If `turbo-sprockets-rails3` is available, remove old assets and | ||
# cache them for next time. | ||
if File.read('Gemfile.lock').include?('turbo-sprockets-rails3') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of grepping the Gemfile.lock you can use rake_task_defined?
method. Then it doesn't depend on the source of the rake task.
Thanks, I've pushed both of those changes |
Using I don't know if any other gems would have any reason to provide an |
Yep, I've received reports that people have used my heroku buildpack successfully with their apps. Here's some benchmarks for the Before / AfterHere's some asset compilation times for a smallish Rails app. Before:
After:
|
Ok, to make sure i'm reading this right you're saying that with no turbo sprockets we are at 26.993 seconds, with turbo-sprockets and no changes we are down to 18.525 seconds, using cached assets we are down to 9.386 seconds (here most of the time comes from detecting the rake task?). Then if we change something and re-compile we're back up to 12 seconds. It was pointed out to me that there is actually an official method for detecting the presence of a gem in the Gemfile using the |
Those benchmarks were actually on a plain Rails app, so most of the 9.386 seconds was just preparing the environment for the task to run. Actually checking for changes only took something like 100ms. So when |
Have updated the pull request with the suggestion above. But it will still make deployments a little slower for people who aren't using the gem |
P.S. The benchmark above was for a pretty small Rails app. I've received emails saying that it cut down their total deploy time from 15 minutes to 2. |
We have used this in production for a much larger application. Initially asset compilation took around 600s, since using this, it has been reduced to 30s. Worth noting we don't use Node to compile, we use therubyracer as it's quite a bit faster for us. |
Have updated the PR to detect the Any cached assets will be deleted if the gem is ever removed, or if the |
Hey, just an update. I'm doing some testing with your buildpack fork, I'll let you know how it goes. |
I'm giving this my 👍 in testing it really cut down on time and didn't seem to have any adverse effects on projects without the gem. Thanks again for your work on the gem and on this PR. Sorry we've been a bit slow, but i'm quite happy with the end result. Now just need the final once over by @hone |
I'd love to see this integrated. |
ping @hone |
Bumpity bumpity bump bump. |
👍 This speeds asset compilation time dramatically on my apps. |
Hello? Still waiting on this one. |
+1 for faster deploys! |
👍 |
This is not pulled yet?? |
I don't think this merges cleanly with master anymore. |
This pull request provides support for the turbo-sprockets-rails3 gem for Rails 3 apps.
If a
assets:clean_expired
Rake task is available, it will remove expired assets and cache them for the next run.