-
-
Notifications
You must be signed in to change notification settings - Fork 204
ISR: Avoiding immense cache-keys generation (Adding the possibility of defining a custom cacheKey) #1743
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
Labels
Comments
@eneajaho I just push a commit to my own fork to handle this, since my company has the same issue. (We used to use our own library to handle SSR, similar with your ISR actually) The idea of the commited change is basically like
I add a bit of unit test for it to ensure the behavior works as it should be. Let me know what you think, I am fine with different approach. |
maxisam
added a commit
to maxisam/rx-angular
that referenced
this issue
Aug 23, 2024
eneajaho
pushed a commit
to maxisam/rx-angular
that referenced
this issue
Aug 31, 2024
eneajaho
pushed a commit
to maxisam/rx-angular
that referenced
this issue
Aug 31, 2024
eneajaho
pushed a commit
that referenced
this issue
Aug 31, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem Solved By The Feature
This is related to #1720 but would be a bit more generic
This is related to #1604 but the fix done there is not fixing the issue described here
We experienced problems using the ISR library since attackers tried to access a lot of urls. Since getCacheKey uses the
req.url
this will lead to a separate cache-entry for each request. Within short time it filled our cache with more than 15GB of data. We had to patch the library in order to usereq.path
for now.E.g.
/my-route?1
,/my-route?something=1
, ,/my-route?something=3
.../something-404
that would look exactly the same but are notI'm aware that this might be the wanted behaviour because of pagination etc. But i want to have the control of modifying this and i am not sure if it's the best default. For simple pages req.path could be an alternative. Even with pagination one could simply iterate over pages and generate an immense amount of entries.
For the 404-Pages I found the solution to not cache it (
revalidate: null
). I will gladly add this as a hint to the documentation to protect other users. So i cannot cache the 404 page, but i also don't create a new entry for every 404-page called.Solution
I would suggest a configuration that lets you specifying your cacheKey-Function. Ideally the interface would allow to pass in the
req
and then users could still allow certain params.For the 404-problem i was first thinking of having a beforeAddingToCache-hook where i can decide from the given response-code if i want to cache it or not.
Alternatives Considered
I did not come up with any other ideas, but happy to discuss it here!
My current workaround:
The text was updated successfully, but these errors were encountered: