Skip to content

How do I limit the size of the cache? #125

@grishka

Description

@grishka

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions