Disappear 103 Early Hints response with Encode enable (Caddy v2.7.6)

1. The problem I’m having:

Using encode directive in CaddyFile with any value (zstd, gzip, br tested) brokes (even disappears) 103 Early Hints in the Caddy response.

I expect 103 Header and gzip/br/zstd-compressed 200 response together, but catch only 200 with encode OR 103+200 uncompressed.

2. Error messages and/or full log output:

no related errors

3. Caddy version:

FrankenPHP v1.1.0 PHP 8.3.3 Caddy v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=
(but clear Caddy v2.7.6 without FrankenPHP has same behavior!)

4. How I installed and ran Caddy:

download binary , or over xcaddy, same effect

a. System environment:

ubuntu 22.04 lts x64

d. My complete Caddy config:

host.ltd {
encode gzip #or zstd or br or together
header +Link "</assets/tmpl/images/back-first-screen-1920-v6.png>; rel=preload; as=image"

respond 103 # or set up Link header via PHP and headers_send(103); with FrankenPHP

file_server # or php_server

i tested with match and also no 103 response:

encode {
    gzip 3
    #match status 2xx 
    #match status 200
    match {
        header Content-Type text/*

I can catch 103 Early Hints header only when remove or comment encode directive in CaddyFile.
Here is my tests with Chrome v122 chrome://net-export/ and visualize with https://netlog-viewer.appspot.com/:
Not working 103 with encode enabled. Here is first response and it is 200:

and working, with encode disabled. Here is first response 103 and 200 after:

As a handmade crutch, i found temporary solution how to get 103 Header and gzip compressed 200 response together: with compress my output via PHP… but i want use on-the-fly compression via Caddy which must working ok, or maybe somewhere my mistake?

Please help or suggest!

5. Links to relevant resources:

Caddy encode directive and FrankenPHP 103 Header docs.

Do you mind trying with http: suppress flushing if the response is being buffered by WeidiDeng · Pull Request #6150 · caddyserver/caddy · GitHub ? I think there’s a chance it might fix it, but I’m not sure. You can use xcaddy to build from that branch.

Thanks for quick response!

I builded xcaddy build fix-6144
and caddy -v prints
v2.7.6-0.20240306201431-830307323e04 h1:yErhQd88gKwaq5PF3cF7Xd9fJTSySkStI4iXT7pV2/s=

…and then i make new tests (only with manual respond 103 in Caddyfile) with same result: status 103 disappears when compression (only gzip tested in this time) enabled.

Can i try something else?

I don’t have any other suggestions unfortunately.

Maybe @dunglas can help, he implemented 103 support in Go.

1 Like

When compression is enabled, the status is not written immediately.

1 Like

@polymer Can you try xcaddy build fix-encode-103?


Hi, i tested it, and it works like a charm :slight_smile:
Caddy version changed:

$ sudo caddy -v
v2.7.6-0.20240310055532-392bc54229a2 h1:nFUS+hHyoZppjLNg0eJyUgbqVuWUJaqlPjpOzw2i7pY=

Netlog catched 103 before 200 code, and content encoded with zstd:

or encoded with gzip:

and i tested without encode, it’s still works :slight_smile: :

Thank you @WeidiDeng !
Now waiting for release with new Caddy!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.