caddyserver / caddyserver/cache-handler
How do I limit the size of the cache?
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 393
- Forks
- 28
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Description
I'm trying to translate this nginx config to Caddy:
https://github.com/grishka/Smithereen/blob/4dcad9dd968b2ae6be04281d6a9ca72d13d4cfc8/examples/nginx.conf
This works but doesn't do so optimally because it would hit imgproxy every time a client requests a resized image:
smithereen.local
encode
# Static files
handle /s/* {
root /var/www/smithereen
file_server
}
# imgproxy
handle /i/* {
reverse_proxy 127.0.0.1:4560
}
# Server application itself
handle {
reverse_proxy 127.0.0.1:4567
}
So I started looking into replicating my nginx setup, where I cache the images processed by imgproxy, and this plugin seems to be the way to do cache on Caddy. Except I couldn't find a way to limit the cache by the combined size of all cached responses instead of the time, so least-recently used responses would get deleted to make room for new ones. Ideally I would just not have any expiration component whatsoever to my caching strategy, but nginx can't do that so I set the TTL to 10 years.
Does this plugin not support this sort of LRU strategy, or did I overlook it? The docs all only talk about the expiration time.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced examples/nginx.conf and the cache plugin's documentation, which currently describes expiration-based caching. Investigate whether the cache implementation exposes a combined response-size limit or LRU eviction, and identify the relevant configuration and tests. Done means documenting the supported behavior or specifying the missing size-based LRU strategy clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, nginx
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100