Skip to content

Getting incomplete responses on cache hit #693

@xico42

Description

@xico42

When using the cache middleware in Caddy I get incomplete response on cache hit.

For example, the root path / of my Laravel APP serves a HTML of 10,5KB. The next request with a cache hit, returns a truncated html sized at 4.1KB.

I have tried to set max_cacheable_body_bytes without success.

My upstream server is a Laravel APP with FrankenPHP (which uses caddy server). At first, I thought that the problem could be the use of early hints in my upstream app, but even after stopping sending 103 HTTP Responses, the problem remains.

Below you may find my Caddyfile and also the Dockerfile used to build a custom caddy image.

{
	debug
	cache {
		ttl 1h
		stale 1d
		default_cache_control private, no-cache, no-store, max-age=0, must-revalidate
		max_cacheable_body_bytes 500000000
		log_level DEBUG
		otter
	}
}

:9000 {
	respond /up 200
}

{$LISTEN_ADDR} {
	log

	@cacheable {
		method GET HEAD
		path /build/assets/* /
		header !X-Inertia
	}

	cache @cacheable

	route {
		header / >Cache-Control "public, max-age=3600"
		header /build/assets/* >Cache-Control "public, max-age=31536000, immutable"
		reverse_proxy app:8000
	}
}
FROM caddy:2.10.2-builder AS builder

RUN xcaddy build \
      --with github.com/darkweak/souin/plugins/caddy \
      --with github.com/darkweak/storages/otter/caddy \
      --with github.com/darkweak/storages/simplefs/caddy

FROM caddy:2.10.2

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Any clues on what might be the root cause for this behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions