-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Eager / proactive sitemap generation #149
Comments
Hi @rudolfbyker, thanks for the suggestion. This makes perfect sense. Ideally, the cache would be built at build time and then recreated with a SWR caching policy. I believe there are some blockers upstream for the build time caching so unfortunately it's not a quick fix. You could experiment with implementing a SWR cache route rules in the meantime. |
Thanks for your time. I did not even think about build time caching. My suggestion would be that we make build time caching a separate feature. On startup, if it was not generated during build time, we simply do it when the server starts. I tried this as a workaround (using very short cache times just for testing):
This totally works, except for two things:
The warmup can be implemented easily using a server plugin, e.g. export default defineNitroPlugin((nitroApp) => {
process.stdout.write("Warming up sitemap …\n");
$fetch("/sitemap_index.xml").then(() => {
process.stdout.write("Sitemap is ready.\n");
});
}); Regarding build-time caching: Do you have links handy to the upstream issues that might be blocking this? |
Update:
|
In v4 when using multi sitemaps and the index sitemap is requested, it won't load all the subsequent child sitemap data anymore. Theoretically, this should be the main blocker? You should be able to split up all of your URLs in other sitemaps to decrease the loading time. Also with the SWR cache enabled it should solve some issues. Happy to re-open if I missed something |
I think this is fine, although it will be a few days before I can look into this again. You just missed my question above:
Any ideas? :) |
Made an upstream PR to hopefully resolve nitrojs/nitro#1906 |
I've pushed up experimental support for this natively, may implement by default in the future. You can try it out with |
Clear and concise description of the problem
Currently, the sitemap is generated on-demand / lazily, i.e. when a request for
/sitemap_index.xml
comes in. My sitemap takes a few minutes to generate, since it is HUGE. What I would like to see is a proactive (re)generation of the sitemap, so that it's always fast when the request comes in.Suggested solution
Config in
nuxt.config.ts
:Expected behavior for
eager=true
:Alternative
The only alternative I can think of is writing my own nitro plugin that does this. But I would rather contribute something here.
Additional context
No response
The text was updated successfully, but these errors were encountered: