Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

Allow users to specify different DefaultMaxAges for different cached paths #27

Open
rickles42 opened this issue Jul 8, 2018 · 0 comments

Comments

@rickles42
Copy link

rickles42 commented Jul 8, 2018

It would be useful if Caddy could treat different cached paths differently, like how Caddy's header directive works. However, looking at setup.go it appears that DefaultMaxAge and other options are global to the whole middleware.

If I try to specify multiple cache blocks in my Caddyfile, Caddy doesn't complain, but I don't see the behavior I would expect:

    cache {
        match_path /foo
        default_max_age 1m
        status_header First-Block-Header
    }

    cache {
        match_path /bar
        match_path /baz
        default_max_age 5m
        status_header Second-Block-Header
    }

In this case I'm not sure whether Caddy is actually instantiating multiple instances of caddy-cache, or if one of the blocks is just getting ignored, but I see all responses using a single same status header.

I suppose a revised syntax would look more like the syntax of header:

    cache /foo {
        default_max_age 1m
        status_header First-Block-Header
    }

    cache /bar /baz {
        default_max_age 5m
        status_header Second-Block-Header
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant