| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@nicolasazrak thanks for the PR and the great looking plugin. Does the cache directive need to be the first plugin? Perhaps if it does you could provide a little explanation, and if not perhaps move it further down the list close to realip and git. |
Sorry, something went wrong.
| "github.com/mholt/caddy/caddytls" | ||
| // This is where other plugins get plugged in (imported) | ||
|
|
||
| _ "github.com/nicolasazrak/caddy-cache" |
There was a problem hiding this comment.
Please remove this
Sorry, something went wrong.
|
@tobya I think I am a little confused about how root works. I expected root to be one of the last ones, so other plugins like gzip had the chance to intercept the content root writes and do something, but I moved cache after git and it seems to be working. |
Sorry, something went wrong.
There was a problem hiding this comment.
I'm really excited to get this plugin in the next release of Caddy. Thanks for working on it! It will help a lot of people!
Sorry, something went wrong.
| "realip", // github.com/captncraig/caddy-realip | ||
| "git", // github.com/abiosoft/caddy-git | ||
|
|
||
| "cache", |
There was a problem hiding this comment.
I'm not convinced this is the right place for this directive in the middleware chain. This list is the order in which middlewares are executed: both during set up and during actual request-time (if they inject handlers).
First things first: to keep track of which directives are third-party plugins, please add a comment to this line with the path to your cache package (as you can see on many of the other lines, sorry if it wasn't explicit in the wiki). // github.com/nicolasazrak/caddy-cache
Next, I think we should move it lower in the list... at least probably not "on its own" like this. I wouldn't know for sure where it belongs, but typically you'll want handlers to go as late in the middleware chain as is possible while having it still work properly. If your handler terminates the chain by serving the response, then the request will never see the rewrite handler, which might break things if people are using it to rewrite URIs. It also comes before the errors directive. Most middleware will want to come after that so that errors returned by your handler can be properly handled. But then again, I don't know for sure in the case of a cache middleware... if you cache the error pages too, then maybe it doesn't matter? (Maybe cache belongs a little lower at least, like where the handler directives are.)
Anyway, I hope that makes sense. If you're unsure, try testing with a few of the directives to see if your cache behaves the way you expect. If not, make sure to move it lower in the chain.
Sorry, something went wrong.
There was a problem hiding this comment.
After looking the order for a while I cannot find the correct place. I think it should be after log and errors but it also should be before gzip and maybe even before ratelimit, but errors is after gzip.
Although being after gzip (or minify) will work, caching gzipped responses can save a lot of cpu. As cache goes lower in the list, more duplicated tasks will be made, defeating the cache purpose which is avoid them. Maybe moving errors after log and putting cache after (log -> error -> cache) would solve the issue.
Being before rewrite should not be a problem because given an request url the rewrite should be the same and caching still applies.
Sorry, something went wrong.
There was a problem hiding this comment.
If being lower in the list will not serve its purpose well, then it's okay to keep it higher. I can definitely understand wanting to keep it above gzip so you can cache compressed responses where clients accept the same encoding.
As long as URL rewrites don't ever have a 1:many mapping, putting cache before rewrite should be fine.
Just don't put it in its own space. ;) The whitespace (empty lines) seem to signal that cache is on its own and I think it's best if it fits in as close as it can with existing groups.
Sorry, something went wrong.
There was a problem hiding this comment.
(To clarify/summarize, in case I wasn't clear: go ahead and leave it where it is, if you think this is best, just put it in the last big group with the others, rather than off by its own.)
Sorry, something went wrong.
There was a problem hiding this comment.
I will leave it after log (without whitespace). Is it ok moving errors after log? So cache errors can be handled. The only problem I see is that error pages will not be compressed, but that should not be a big problem.
About rewrite having 1:many mapping, in that case rewrite should add Vary header to inform that depending on some header the response could change.
Sorry, something went wrong.
There was a problem hiding this comment.
No, don't reorder any of the other directives. Just leave cache where it best belongs, which after your investigation, is apparently in this place. Just remove the whitespace so it fits in the group. Thanks!
Sorry, something went wrong.
|
Waiting for @elcore to approve and then will merge. 👍 Thank you, Nicolas! You can publish your plugin immediately after the next release of Caddy. If it needs to be re-ordered in this list, you can do so most efficiently before that release. 😉 |
Sorry, something went wrong.
|
@mholt thanks I'll be waiting for the next release ! |
Sorry, something went wrong.
|
@nicolasazrak The new version is out, you may now publish this plugin! |
Sorry, something went wrong.
|
@nicolasazrak If you'd ever be interested in helping to build the v2 equivalent of a caching middleware, we have a repo for it now: https://github.com/caddyserver/cache-handler - just FYI, you're not obligated or anything :) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
After a long time I finally think caddy-cache is ready to be published. It does not have every feature I want but I think it handles the basic thinks it needs to support:
What do you think?
1. What does this change do, exactly?
Adds a middleware for http caching
2. Please link to the relevant issues.
#10
3. Which documentation changes (if any) need to be made because of this PR?
It needs a new section for the new cache directive
4. Checklist