Comments

35 comments

  • Leo Jiang

    Hi, the snippets provided don't work for me. I tried debugging by adding these headers:

    set resp.http.X-Fastly-Accept-Encoding = req.http.Fastly-Orig-Accept-Encoding;
    set resp.http.X-Fastly-Accept-Encoding-2 = req.http.Accept-Encoding;

    My request headers contain:

    accept-encoding: gzip, deflate, br

    However, the response headers are:

    x-fastly-accept-encoding: gzip
    x-fastly-accept-encoding-2: gzip

    My recv snippet contains:

    if (req.http.Fastly-Orig-Accept-Encoding && req.url ~ "(.+\.js)(\?|$)") {
      set var.path = re.group.1;
      if (req.http.Fastly-Orig-Accept-Encoding ~ "br") {
        set req.http.Accept-Encoding = "br";
        set var.path = var.path ".br";
      }
      set req.url = var.environment var.path;
    }

    This never loads the Brotli files. Gzip is also disabled on Fastly.

    Edit: I realized this might be because my company runs Cloudflare in front of Fastly for some reason.

    0
    Comment actions Permalink
  • Daixtech

    NICE, going to opne a ticket right now ;)

    0
    Comment actions Permalink
  • john mcilwain

    the "official comment" has a link which is broken...(titled 'this comment')

    thx!

    0
    Comment actions Permalink
  • Dara Roberts

    john mcilwain Thanks for letting me know! I'll get that fixed :) 

    0
    Comment actions Permalink
  • Jack

    I wonder why Fastly normalize an Accept-Encoding for backend ?

    just doing this allows client & origin server do content negotiation.

    set req.http.Accept-Encoding = req.http.Fastly-Orig-Accept-Encoding;

    and origin server returns Vary header correctly, it should also works for Fastly too.

    is there any reason to force normalize in single candidate like below ?

    (or If it only for IE things, It can be like below too)

    if (req.http.Fastly-Orig-Accept-Encoding) {
    if (req.http.User-Agent ~ "MSIE 6") {
    unset req.http.Accept-Encoding;
    } else {
    set req.http.Accept-Encoding = req.http.Fastly-Orig-Accept-Encoding;
    }
    }

     

    0
    Comment actions Permalink

Please sign in to leave a comment.