Skip to content

Instantly share code, notes, and snippets.

@sj26
Last active May 13, 2023 04:42
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sj26/4728657 to your computer and use it in GitHub Desktop.
Save sj26/4728657 to your computer and use it in GitHub Desktop.
Don't discard cache during asset precompile. Full explanation and caveats: http://sj26.com/2013/02/09/the-asset-pipeline-isnt-actually-slow
# Stick this in lib/tasks/assets.rake or similar
#
# A bug was introduced in rails in 7f1a666d causing the whole application cache
# to be cleared everytime a precompile is run, but it is not neccesary and just
# slows down precompiling.
#
# Secondary consequences are the clearing of the whole cache, which if using
# the default file cache could cause an application level performance hit.
#
# This is already fixed in sprockets-rails for rails 4, but we patch here for
# interim gains.
#
# If you're using rails pre-3.2 change "primary" to "digest" below.
Rake::Task["assets:precompile:primary"].prerequisites.delete "tmp:cache:clear"
Rake::Task["assets:precompile:nondigest"].prerequisites.delete "tmp:cache:clear"
@raskhadafi
Copy link

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment