↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Caching in development environment in Rails 5

Rails 5 adds a command for turning development caching on and off without editing config/environments/development.rb by hand. The command creates or removes tmp/caching-dev.txt, and the app uses that file to decide whether caching is enabled in development.

Reading notes
#

  • In Rails 4, enabling caching in development required changing configaction_controllerperform_caching in config/environments/development.rb and restarting the server.
  • Rails 5 introduces rails dev:cache to help test caching behavior in development mode.
  • Running rails dev:cache creates tmp/caching-dev.txt and prints that development mode is now being cached.
  • In a new Rails 5 app, development.rb checks whether tmp/caching-dev.txt exists and then uses :mem_cache_store when it does.
  • The dev cache code toggles the file in tmp/caching-dev.txt and touches tmp/restart.txt.
  • The advantage is that caching can be turned on or off without restarting the server manually.
  • The feature is not supported by unicorn, thin, and webrick.
  • Running rails dev:cache again disables development caching if it was previously enabled.