about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>2022-11-14 04:26:49 +0000
committerGitHub <noreply@github.com>2022-11-14 05:26:49 +0100
commit9d039209cc0791ec09ebdbb93da4d63f815e1b07 (patch)
tree6c572e08fd0ab2d71cc33ead2139f9fe4e94d2d4
parentd0b7bd42501fcf704dbfead4cc1c08ced49371a8 (diff)
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.
-rw-r--r--config/initializers/paperclip.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb
index 5c182ade4..a2285427c 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'],