File_server: file download too slow in web browser, but fast with wget/curl

1. The problem I’m having:

Using caddy as a file server.
caddy (v2.9.1):
When downloading file in a web browser, the speed was very slow, less than 100 KB/s when it should be around 5 MB/s.
When downloading with wget or curl in a terminal, the speed was as expected, i.e. about 5 MB/s.

caddy (v2.7.4):
No such problem. Web browser/wget/curl, the download speeds were virtually the same, i.e. about 5 MB/s.

Tested multiple times with both caddy versions. Web browsers are chromium version 135.0.7049.52 (Official Build) Arch Linux (64-bit) and firefox 137.0 (64-bit). The results were consistent.

2. Error messages and/or full log output:

no error message

3. Caddy version:

v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=

4. How I installed and ran Caddy:

a. System environment:

Debian 12 6.1.0-29-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.123-1 (2025-01-02) x86_64 GNU/Linux

b. Command:

wget https://github.com/caddyserver/caddy/releases/download/v2.9.1/caddy_2.9.1_linux_amd64.deb
dpkg -i caddy_2.9.1_linux_amd64.deb.

c. Service/unit/compose file:

# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

d. My complete Caddy config:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

my.site {
        # Set this path to your site's directory.
        root * /var/www

        # Enable the static file server.
        file_server browse

        # Another common task is to set up a reverse proxy:
        # reverse_proxy localhost:8080

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile

5. Links to relevant resources:

Enable access logs and, for good measure, enable debug logs too.

What is the full log output when you try to download the file from curl and then the web browser?

My guess is it’s something weird the browser is doing, maybe a quirk with a protocol version.

1 Like

Hi Matt,

Thank you very much for your reply. I turned on the log and noticed the difference seems to be wget is using HTTP/1.0 and curl is using 2.0 and the web browser is using 3.0. So I disabled 3.0 by adding the following in Caddyfile:
{
servers {
protocols h1 h2
}
}

Problem solved.

But is this a bug of v2.9.1?

Thanks for the update!

Possibly. I’ll pass this along to the team.