Is there any way to incrementally regenerate the wp-search.json file? #470
Replies: 2 comments 2 replies
-
hey @spencersmb i suspect this question came before the video of mine you found: https://www.youtube.com/watch?v=_isECpf3-8s that's certainly an option (and currently what im doing on my site as i just haven't implemented it yet (procrastinating)) but ISR is probably going to be your friend here: https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#on-demand-revalidation you can create an endpoint that serves as the endpoint WordPress would hit as part of a webhook you would need to be able to pass in the route you want to refresh or have a way of looking it up |
Beta Was this translation helpful? Give feedback.
-
@colbyfayock - Really appreciate the help man. I think I ended up coming up with a decent solution. I'd be curious to get your thoughts on it. Basically I have a blog with over 600+ posts that I want to use with next, but I don't want to have to rebuild each week on a new blog post. Cue your awesome video to help solve that problem! So I still want super fast search using my wp-search.json file but again, don't want to have to rebuild the whole site each week. Solution: Each week when a new post publishes, I have an action in wordpress that fires only when a post publishes. This makes an api call in PHP to an API route on my next website. That Api Route then fetches the latest data from my backend, and saves/overwrites the json file on my S3 bucket. AWS will then clear the cache with an updated file. And now we don't have to rebuild each week. What do you think? |
Beta Was this translation helpful? Give feedback.
-
I have a fairly large blog and was considering going next.js / headless and wondering if I would need to rebuild each time a new post gets released weekly.
Great work on this repo!
Beta Was this translation helpful? Give feedback.
All reactions