nicolasazrak / caddy-cache

Caching middleware for caddy
Mozilla Public License 2.0
109 stars 30 forks source link

Cache directive breaks rewrite #23

Closed faradaytrs closed 6 years ago

faradaytrs commented 6 years ago

More information here https://caddy.community/t/rewrite-nginx-rewrite-block-to-caddy/3582/26

nicolasazrak commented 6 years ago

This seems to be an issue of the ordering in the middleware chain. cache is before rewrite (https://github.com/nicolasazrak/caddy/blob/master/caddyhttp/httpserver/plugin.go#L456) so it will cache the original url and not the rewritten one. I will make a few tests, if this is the problem I'll make a PR on the caddy repo to change that.

faradaytrs commented 6 years ago

I tested that before and it was broken in both before and after rewrite, but you'd better test it again.

faradaytrs commented 6 years ago

I just tested it and it doesn't work wherever you place it.

nicolasazrak commented 6 years ago

After investigating #22 it seems that both issues are the same. The ordering issue was my first guess but it seems it's not. I pushed a commit to master that fixes this issue. I cannot deploy it yet because of a problem in caddy infrastructure (https://github.com/mholt/caddy/issues/2106)

faradaytrs commented 6 years ago

Has this been fixed?

nicolasazrak commented 6 years ago

It should be fixed by the latest master commit. But until caddy fixes https://github.com/mholt/caddy/issues/2106 I cannot deploy it to caddy website.

faradaytrs commented 6 years ago

so should we just wait for a new caddy release?

nicolasazrak commented 6 years ago

Exactly, sadly I can't do anything right now. If you really need this fix you can compile your own version of caddy.

faradaytrs commented 6 years ago

Nah, i think they are about to release new version

faradaytrs commented 6 years ago

Problem is still there on caddy 0.10.13

nicolasazrak commented 6 years ago

I've just deployed the new version, try downloading caddy again

faradaytrs commented 6 years ago

Thanks it worked!