How to set S3 asset expiry age with @strapi/provider-upload-aws-s3?

Hi all,
I am using "@strapi/provider-upload-aws-s3": "^4.12.1", and it works very well in its basic usage.

I have only one issue that when uploaded to s3 no Expires is set, and my assets served via Cloudflare with source S3 have no cache ttl.
Google page speed insights also complains that these assets:

A long cache lifetime can speed up repeat visits to your page. Learn more about efficient cache policies.

How can I specify some cache time for this plugin when it uploads stuff to s3 ?

1 Like

Iā€™m looking for the same thing, have you find a solution?

For future reference if anyone is looking for this.

/config/plugins.js

upload: {
    config: {
      provider: "aws-s3",
      providerOptions: {
        baseUrl: env("CDN_BASE_URL"),
        rootPath: env("CDN_ROOT_FOLDER"),
        s3Options: {
          accessKeyId: env("AWS_ACCESS_KEY_ID"),
          secretAccessKey: env("AWS_ACCESS_SECRET"),
          region: env("AWS_REGION"),
          params: {
            Bucket: env("AWS_BUCKET_NAME"),
            CacheControl: "public, max-age=31536000", // 1 year: 60*60*24*365 = 31536000
          },
        },
      },
    },
  },```