Lambda@Edge for serving Brotli or Gzipped file according to the Content-Encoding header. It supports CSS and JS files.
- Use S3 && Cloudfront
- You MUST upload your CSS & JS files already compressed to the bucked. In other words, you MUST upload the same file three times: without compression, compressed with Brotli (and .br extension), compressed with Gzip (and .gzip compression).
- You MUST deactivate
gzip
on-the-fly compression from CloudFront settings. - Use this Lambda@Edge in order to intercept Requests for CloudFront.
Useful resources: Get Lambda Event Source Gist