Search code examples
cachinggzipamazon-cloudfrontamazon-elastic-beanstalkddos

Why doesn't CloudFront GZIP my HTML/JSP pages


I've configured CloudFront in front of my Elastic Beanstalk/load-balanced web application and the static content rule (Png images etc) are being caching and served GZIPPED.

However my JSP pages aren't being Gzipped.

Please note that I have explicitly set my default rule to not cache by setting the min TTL to 0, but it's probably un-necessary because my origin server isn't returning a Content-Length header for JSP pages, so it will never be cached anyway.

CloudFront will only cache if...

  1. Filetype is supported (text/html is)
  2. Response is 1,000 -> 10,000,000 bytes (it is)
  3. Content-Length header must be provided (it is NOT)
  4. Content-Encoding must not be set (it is not)

So that explains why it's not being cached, fair enough.

But why don't my HTML pages get GZIPPED? FYI my HTML and JSP file extensions are all processed through the JSP processor.

Network Diagnostics

Static Behavior (works)

Default Behavior (no GZIP)

Origin Settings


Solution

  • Looks like I was right, until my page was modified to return the Content-Length response header, CloudFront did not cache nor GZIP the content.