Skip to content

Commit 455b7dc

Browse files
committed
Set long max-age to make assets more cacheable
Since these are keyed by their md5 hash we can cache them for a long time (I've chosen 7 days). R2 does add an etag, but the adding this will mean etags won't need to be checked and might enable cloudflare to do more caching.
1 parent d08f06c commit 455b7dc

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/scratch_asset_importer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def save_to_editor_asset_bucket
6464
bucket: ENV.fetch('EDITOR_ASSETS_BUCKET'),
6565
key: asset_key,
6666
body:,
67-
content_type: asset_content_type
67+
content_type: asset_content_type,
68+
cache_control: 'public, max-age=604800'
6869
)
6970
end
7071

spec/lib/scratch_asset_importer_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
bucket: 'test-bucket',
9292
key: 'internalapi/asset/123abc.png/get/',
9393
body: instance_of(StringIO),
94-
content_type: 'image/png'
94+
content_type: 'image/png',
95+
cache_control: 'public, max-age=604800'
9596
)
9697
end
9798

0 commit comments

Comments
 (0)