Generating a sitemap on build/start?

MattIPv4
0
MattIPv4
commented a month ago

I'm using the standard(?) nuxt build and then nuxt start commands to run my app. I have a rather complex sitemap that takes some time to generate

I've enabled the sitemap caching option, but is there any programmatic way to generate the initial sitemap during build or start so that the first request doesn't have to wait?

Equally, is there any way to schedule a task that will re-generate the sitemap in the background so that no request ever has to wait for the cache to be refreshed if it expires?

0
NicoPennec
2.0k
NicoPennec
commented a month ago

Hi @MattIPv4

Currently the cache is already hydrated on "start" (see https://github.com/nuxt-community/sitemap-module/blob/dev/lib/middleware.js#L55-L62).

If you want to schedule a task to re-generate the simple way is to create a Cron job on a server to run a simple wget command (eg. wget --spider https://example.com/sitemap.xml). The sitemap-module cannot do that, sorry.

0
Informations
Question โ€ข Unresolved
#c91 - Created a month ago