caddyserver / cache-handler

Distributed HTTP caching module for Caddy
Apache License 2.0
262 stars 19 forks source link

Badger or Nuts? #31

Closed DzigaV closed 2 years ago

DzigaV commented 2 years ago

@darkweak I've just seen this PR, which adds support for Nuts: https://github.com/caddyserver/cache-handler/pull/30

Is Nuts now recommended over Badger? If so, how is it enabled in the CaddyFile?

A related question: are Badger and Nuts in-memory by default?

darkweak commented 2 years ago

Hey @DzigaV, you can follow the README on the branch https://github.com/caddyserver/cache-handler/tree/feat/dependencies/bump-to-souin-v1.6.14#example-configurations.
To enable it you have to set the etcd directive with the configuration and use the etcd configuration naming https://pkg.go.dev/go.etcd.io/etcd/clientv3#Config e.g. :

cache {
    etcd {
        configuration {
            Endpoints 192.168.1.123 192.168.1.124
            AutoSyncInterval 10s
        }
    }
}
mholt commented 2 years ago

Which do you recommend @darkweak ?

darkweak commented 2 years ago

@DzigaV I updated the example documentation that should be used on the cache-handler repository in this PR https://github.com/darkweak/souin/tree/feat/core/configurable-timeout-on-backend-and-cache-access/plugins/caddy.
Let me know if some parts are not well explained.

@mholt I recommend to use Olric and Badger first but in some edge cases Olric has desyncs in a K8s cluster (@eth-limo got this issue). So, in a K8s environment I recommend etcd if you need some distributed storage (but it takes more resources than Olric). And sometimes Badger run into a cache pollution and serves mismatched contents when your RAM limit is too low (when you try to store some huge responses in the Badger cache it gets corrupted, this was discover by @mattvb91). I recommend to use nutsdb on this case. But for 90% use cases Badger and Olric are good to use and lighter than the alternatives.