From 9d039209cc0791ec09ebdbb93da4d63f815e1b07 Mon Sep 17 00:00:00 2001 From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Mon, 14 Nov 2022 04:26:49 +0000 Subject: [PATCH] Add `Cache-Control` header to openstack-stored files (#20610) When storing files in S3, paperclip is configured with a Cache-Control header indicating the file is immutable, however no such header was added when using OpenStack storage. Luckily Paperclip's fog integration makes this trivial, with a simple `fog_file` `Cache-Control` default doing the trick. --- config/initializers/paperclip.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 5c182ade489..a2285427c80 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -125,6 +125,8 @@ elsif ENV['SWIFT_ENABLED'] == 'true' openstack_region: ENV['SWIFT_REGION'], openstack_cache_ttl: ENV.fetch('SWIFT_CACHE_TTL') { 60 }, }, + + fog_file: { 'Cache-Control' => 'public, max-age=315576000, immutable' }, fog_directory: ENV['SWIFT_CONTAINER'], fog_host: ENV['SWIFT_OBJECT_URL'],