adobe / helix-publish

Microservice for publishing Project Helix Fastly service configurations
Apache License 2.0
5 stars 6 forks source link

Enabling gzip compression on Fastly #109

Open ryanbetts opened 5 years ago

ryanbetts commented 5 years ago

So, as @trieloff was mentioning, turning on the default Fastly gzip compression interferes with ESI processes. I double checked and sure enough it does.

More info here:

I spoke with Fastly's support and they recommend the following:

"So you can enable gzip in the UI of the service. for ESI you will want to add this snippet to vcl_fetch:

/* Turn on ESI for root GETs */
if (req.url == "/esi_example.html") {
    set beresp.do_esi = true; /* Do ESI processing */
    esi;
    set beresp.ttl = 5s; /* Sets the TTL on the HTML above */
}

That should set up the gzip and ESI functionality.

If you are using shielding you will want to add this to vcl_recv:

if (req.http.Fastly-FF) {
    set req.esi = false;
}

I hope that helps."

From speaking with @filmaj I understand that Helix is responsible for generating all the varnish files so I thought I'd kick this over to you. How best can I go about enabling gzip using the above changes?

tripodsan commented 5 years ago

at least we could ensure to disable ESI for static requests.

tripodsan commented 5 years ago

also, ensure to enable it in fastly:

image

tripodsan commented 5 years ago

Doing this, disabled the ESI processing for the static includes, and it breaks the site:

image

trieloff commented 5 years ago

We use ESI at the moment for following content types:

If we build something like I outlined here: https://github.com/adobe/helix-pipeline/issues/365#issuecomment-501218592 (move the ESI processing to Runtime) we would be able to have Gzip across the board.

tripodsan commented 5 years ago

If we build something like I outlined here: adobe/helix-pipeline#365 (comment) (move the ESI processing to Runtime) we would be able to have Gzip across the board.

or if we put the helix-specific service as an origin behind the real service, as mentioned here: https://github.com/adobe/helix-pipeline/issues/365#issuecomment-501494532 ;-)