Ensure that preference keys are not prefixed with '/' if ENV['RAILS_CACHE_KEY'] is not set

Fixes #3831