-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Etag middleware #692
Comments
Maybe good to note, I'm aware that in the code above we:
All these should be resolved but I thought I'd start by checking with more experienced people what the first steps would be while at the same time posting something that has handled a few million requests successfully (: |
Hi! I think this type of middleware probably could exist in |
I think realistically it would be easier to iterate outside of tower-http and then merge it when it has matured a bit. |
Works for me, I can close this. Where could I get help on tower? It's the main reason I opened here. I know a bunch about etag middleware now, but writing tower middleware / Rust is still hard for me. Especially if we're talking making zero allocations etc. But first step would be stuff like not buffering the bytes in a clumsy loop and I'm not sure where to learn about that. Been writing Rust for a couple months only and am solo on my team. |
@alextes we have a #tower channel on the https://discord.gg/tokio that we can help you out in for general tower stuff. |
was development of this ETag middleware moved to some other repo? |
I don’t know of any. |
I've started on an implementation at https://github.com/billythedummy/tower-etag-cache/tree/master/tower-etag-cache. The implemented |
I was quite surprised to find nothing about etag middleware anywhere. No blog posts, no crates, no builtin middleware. Etags, although far from necessary, are quite important to help apps not download data over and over, but I'm sure folks in this repo know more about that than me 😄 .
So instead of saying Etag middleware is important! and then complaining no one has written it yet, I did the nicer thing and tried to write it myself. I'm new to Rust so not the ideal situation but that's life.
requirements:
This is the (monster) I came up with 😅 .
Having to write this came at the worst possible time and ended up with the predictable late-hour debugging of caching issues due to this piece of code (who knew you need to send the hash even on a 304 🙈 ). Luckily, bugs were fixed and our big day was still successful 🥳 .
I'd like to save others from writing their own, but I could really use some help.
The blob above works with axum's middleware::from_fn. Would the first step be rewriting it to a tower
Service
?Thanks for the great foundation Axum appears to be built on top of 💛 !
The text was updated successfully, but these errors were encountered: