colbyfayock / next-wordpress-starter

📝 Bring WordPress to the static world with Next.js
https://next-wordpress-starter.spacejelly.dev
MIT License
1.2k stars 291 forks source link

ISG for a lot of content #598

Open Borea opened 6 months ago

Borea commented 6 months ago

Hello, I have a website with a 15k posts, and I want to use ISG but query inly return 100 posts maximum. I tried this solution https://stackoverflow.com/questions/70175630/wp-graphql-query-only-returns-first-100-posts-when-generating-sitemap but my website collapse... I spen a day trying to find a solution to prerender 15k posts, or 1k and the next rendering in the server.

Can you please help me or some idea why can I do in this case. Ty

colbyfayock commented 6 months ago

hey @Borea thats a great question and i dont think i have a good answer, so maybe someone else can chime in

that said, is it critical to prerender that many posts to start? i think generally speaking, thats a pretty huge query, and it would be a slow one

something you may also want to consider is caching your wordpress queries which may help in certain situations:

tutorial: https://www.youtube.com/watch?v=9QIMXxDSAyQ

Borea commented 6 months ago

Hello, thanks for you repply @colbyfayock and sorry for my bad english.

I will check the video, thanks. But in cases like wp-search.json archive? I need to fetch all items to stored in json search or can be uptated if i request a content who is not initial builded? Same question for pagination, for example I have a pagination with 10 pages because I only can fetch 100 items (10 per page) if I request 10 items who are not pre builded, when build, thats items will appear in a new page in pagination?

Im a lot of questions, I will check you channel, thanks again.

Fran-A-Dev commented 6 months ago

Hi @Borea , I'm Fran, from DevRel at WP Engine and I focus on headless WordPress. I was asking around in our headless WP Discord server and what I got are these options you could do.

Instead of rebuilding the entire search index with each change you could implement and modify something like a hook into WP post's save and delete actions which would require some back-end code in WP to trigger these updates to your static JSON file.

And for the initial build of the search index or complete rebuilds, use the batch processing approach to fetch all content. The server load is what I'm concerned about here.

The pagination updates would be handled dynamically client side on items that are not prebuilt. You can use ISR here. You could also fallback and load for items not prebuilt and fetched client side and displayed dynamically.

This will be a huge JSON file. The other route you could do is an advanced search or just the WP search. Hopefully this helps a little.

Borea commented 6 months ago

Hi @Borea , I'm Fran, from DevRel at WP Engine and I focus on headless WordPress. I was asking around in our headless WP Discord server and what I got are these options you could do.

Instead of rebuilding the entire search index with each change you could implement and modify something like a hook into WP post's save and delete actions which would require some back-end code in WP to trigger these updates to your static JSON file.

And for the initial build of the search index or complete rebuilds, use the batch processing approach to fetch all content. The server load is what I'm concerned about here.

The pagination updates would be handled dynamically client side on items that are not prebuilt. You can use ISR here. You could also fallback and load for items not prebuilt and fetched client side and displayed dynamically.

This will be a huge JSON file. The other route you could do is an advanced search or just the WP search. Hopefully this helps a little.

Thanks for ideas. I have resumed the project this day again and I will try this thread suggestions.