Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ISR: Render behaves differently between render / regenerate / invalidate #1758

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

Closed
maxisam opened this issue Aug 23, 2024 · 6 comments
Closed

Comments

@maxisam
Copy link
Contributor

maxisam commented Aug 23, 2024

Description

only render has feature for modifyGeneratedHtml, it is missing from the other two

I think the issue here is we should consolidate the render function a bit more.

also with modifyGeneratedHtml, I think there is no need for cacheMsg in InMemoryCacheHandler

We can have a default modifyGeneratedHtml function just like cacheMsg

Notes

I will try to fix this in my fork, if you like the proposed solution, I will make a PR.

Sorry making a bunch of changes in a short time, I am trying to port our existing feature to this library. My goal is trying to match the upstream as much as possible.

@maxisam maxisam changed the title ISR: Render behaves different between render / regenerate / invalidate ISR: Render behaves differently between render / regenerate / invalidate Aug 23, 2024
@eneajaho
Copy link
Member

Yes, that would be great! Thanks for doing all this! I will make sure to review and merge everything!

@maxisam
Copy link
Contributor Author

maxisam commented Aug 24, 2024

Thanks! Your library is really awesome.

So my current plan is rename regeneration to generation and add another param for different mode, since they actually behave a little different. But I might change my mind after working on this a bit more.

I plan to do this one first and then #1755

Welcome to give me any suggestion.

@maxisam
Copy link
Contributor Author

maxisam commented Aug 28, 2024

I think we shouldn't have 2 different configs to modify the html for serveFromCache and render

modifyGeneratedHtml?: (req: Request, html: string) => string;

modifyCachedHtml?: (req: Request, html: string) => string;

I understand the need to have a way to serve different variant of a page, but variants to do that already.

with 2 different configurations,

we have to provide render config here (which is missing currently)

await this.cacheRegeneration.regenerate(
req,
res,
cacheData,
this.logger,
config?.providers,
);
}
}

If we only allow one config for that, we can just add providers and modifyCachedHtml to ISRConig and use the ISRConfig for everything.

Any thought?

@maxisam
Copy link
Contributor Author

maxisam commented Aug 28, 2024

Actually, I think I can still preserve modifyCachedHtml in ServeFromCacheConfig to avoid breaking change.

But I think we have to add modifyGeneratedHtml in ISRHandlerConfig

maxisam added a commit to maxisam/rx-angular that referenced this issue Aug 29, 2024
@maxisam
Copy link
Contributor Author

maxisam commented Aug 29, 2024

I push a commit to show the idea. I will test it more tomorrow but I think it should work. It does change a lot of code so feel free to give me some feedback.

eneajaho pushed a commit that referenced this issue Aug 31, 2024
)

* refactor(isr): rename CacheRegeneration to CacheGeneration
* refactor(isr): rename CacheRegeneration to CacheGeneration
* fix(isr): handle modifyGeneratedHtml behavior consistantly #1758
* refactor(isr): use modifyGeneratedHtml instead
* feat(isr): update the example to show modifyGeneratedHtml usage
@maxisam
Copy link
Contributor Author

maxisam commented Sep 17, 2024

this is done

@maxisam maxisam closed this as completed Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants