Gzip/Brotli compression with CloudFront doesn't work on URL rewriting?

71 Views Asked by At

CloudFront provides automatic compression of web pages. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html

The environment of our website is very typical, it is LAMP and the URL rewriting of each page is set up in .htaccess. The URLs look like:

  • https://stackoverflow.com/questions/47159895/gzip-compression-with-cloudfront-doesnt-work
  • https://stackoverflow.com/search?q=cloudfront+compression

CloudFront's compression seems doesn't work on our rewritten URL pages (Content-Type: text/html, but they don't have any filename.ext in the URLs), whether it is Gzip or Brotli.

During repeated testing, I also invalidated the files from edge caches again and again.

To verify whether there is a URL rewriting problem, under the same environment and settings, the .js and .css files can be compressed and Brotli (Content-Encoding: br) is automatically used.

Does anyone have any successful experience with using CloudFront's compression on web pages that have had URLs rewritten?

0

There are 0 best solutions below