Switched to Redis cache in production (#761)

This commit is contained in:
farhatahmad
2019-08-22 14:09:39 -04:00
committed by Jesus Federico
parent d3eb064b96
commit cfab2fd191
3 changed files with 24 additions and 1 deletions

View File

@ -16,7 +16,22 @@ Rails.application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.cache_store = :memory_store
if ENV['REDIS_URL'].present?
# Set up Redis cache store
config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'],
connect_timeout: 30, # Defaults to 20 seconds
read_timeout: 0.2, # Defaults to 1 second
write_timeout: 0.2, # Defaults to 1 second
reconnect_attempts: 1, # Defaults to 0
error_handler: lambda { |method:, returning:, exception:|
config.logger.warn "Support: Redis cache action #{method} failed and returned '#{returning}': #{exception}"
} }
else
config.cache_store = :memory_store
end
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.years.to_i}"
}