-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Wrong cache key #467
Comments
Hi! Interesting issue! Indeed the a middleware would not be the right place to do this as it's too late at this point. I'm curious what the purpose is for sorting? If it's just to improve caching behavior, I wonder if it's sufficient to just subclass the Cache class and do a normalization step there. But if you want to hook this into absolutely everywhere, there's a number of places where the URIs would need to be normalized. I would probably try to rewrite these as you are receiving the urls from the server. |
Hi ! It is indeed for a question of performance / use of the cache. Our backend returns links with href where one part of the query params is templated and not the other, in the following form: ?objectId=12&{from,to}. Example : I thought that making a middleware that sorts the params would be enough, but obviously not. I don't know if everything is clear. |
The issue is that there's a lot of potential places where URIs are passed along. What mechanism do you currently used to invalidate the cache? This sounds like it's a job for Regardless I do think it's kind of an interesting use-case and I wonder if Ketting should have a better mechanism for servers to specify their main url if there's variants |
To invalidate the cache, our backend returns in the links a list of impacted resources. This works pretty well, except when the resource href has query params where the order has an impact 😁 |
This is starting to be urgent for us, we have several bugs on our project because of this. |
Hey, honestly the best possible ways (in this order) are probably:
Here's the base class for caches: https://github.com/badgateway/ketting/blob/main/src/cache/forever.ts If you have a budget also happy to consult a bit with this for a few hours. P.S.: Also a dominion fan! |
Hello ! |
Hi !
I have a middleware that changes the request URI to sort query params, it works fine.
However, the caching middleware continues to use the premodified URI for caching.
Is there a solution to fix this problem?
The text was updated successfully, but these errors were encountered: