forked from External/greenlight
Switched to Redis cache in production (#761)
This commit is contained in:
committed by
Jesus Federico
parent
d3eb064b96
commit
cfab2fd191
@ -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}"
|
||||
}
|
||||
|
Reference in New Issue
Block a user