caddyserver / cache-handler

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

can't figure out badger #37

Closed tve closed 1 year ago

tve commented 1 year ago

I'm trying to cache a 2.7MB response and I get a badger error (see #8):

Oct 10 09:12:24 cloud caddy[2743409]: {"level":"debug","ts":1665418344.1734848,"logger":"http.stdlib
","msg":"http2: panic serving 0.0.0.0:56316: Impossible to set value into Badger, Value with si
ze 2779485 exceeded 1048576 limit. Value:\n00000000  48 54 54 50 2f 30 2e 30  20 32 30 30 20 4f 4b 0

Looks like there's a 1MB limit. The README points to "See the Badger configuration for the options" which links to https://dgraph.io/docs/badger/get-started/. Well, I'm probably blind, but I don't see any documentation about configuration there.

I'm also not finding any information on how the cache handler uses badger (store metadata, store responses, store ...?). Nor on what the default configuration is. E.g. is it used as in-memory cache, or on disk? If the latter, where is the data stored on disk? ...

I tried the following, but it doesn't change the error:

        route /data/* {
                cache {
                        badger {
                                configuration {
                                        MemTableSize 8000000
                                        ValueThreshold 4000000
                                }
                        }
                }
                reverse_proxy https://motus.org {
                        header_up Host motus.org
                }
        }

Putting the badger config in the global cache directive has the same results.

mattvb91 commented 1 year ago

Personally I would recommend using the nutsdb setup, badger has been nothing but unstable for myself. (I am also caching pretty big full page responses).

In the latest version redis support has also been added which may be an even better option. Caddy caching in general is still pretty flakey but its definitely getting better with the latest releases.

darkweak commented 1 year ago

Hi @tve can you retry with the latest version please?

jpds commented 1 year ago

I also had this issue with the latest master commit and traced it down to: https://github.com/dgraph-io/badger/issues/60

darkweak commented 1 year ago

@jpds same as explained here https://github.com/caddyserver/cache-handler/issues/55#issuecomment-1638919674