Replies: 4 comments 13 replies
-
Hello @priard. Thank you for the heads up. We will investigate this feature as part of the larger effort to revalidate content on demand. Looking at this workflow though, I would be very cautious on having the main WordPress backend trying to trigger anything to the Front-end site URL. With regular WP this is not an issue. But in the Headless worlds there should be only a one way communication (from the Front-end site URL to WP backend and not vice versa) to reduce any coupling scenarios. However ( I haven't verified though ) this could be done with any plugin/hook that triggers webhooks on post update/create like this one. Here are some rough steps:
I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hi @theodesp I'm trying to implement on demand ISR revalidation. On the homepage, I'm using default usePosts hook. |
Beta Was this translation helpful? Give feedback.
-
So the revalidation basically works, not without problems (problems with the query cache mixing), but there is also a solution for that (the latest version of GQty 2.3.0). @bebjakub showed what a more advanced implementation might look like. I think it is worth extending FaustWP with these functions and adding revalidation in the example implementation + expand the documentation. [1] On-Demand Revalidation |
Beta Was this translation helpful? Give feedback.
-
I have a moment, so little update on on-demend revalidation. I basically rewritten my application to switch from GQty to Apollo Client and the revalidation problems are completely gone. Additionally, this way I managed to reduce "First Load JS" by 30-40 kB per route. I also rewritten WordPress Post / Page preview to work with Apollo, but that's where the problems started. It turned out that Apollo has a few long-unresolved bugs that make working with useQuery and useLazyQuery difficult (infinite loops, non-firing queries, and other bugs). So I decided to rewrite the application again and replace Apollo with urql library. From that moment on, the problems ended. Everything works correctly and quickly, and interestingly again - thanks to this change - I was able to reduce the size of the application by another ~ 30 kB. I rewrote the preview, rewritten handleSitemapRequests (middleware does rewrite to api / faust / xml route I added to handle sitemap / rss / robots requests) to work with next.js 12.2.x, added sitemap-like rss support and it works together very well. I wrote all of this to let you know that it's worth switching to urql right away and not bothering with either GQty or Apollo Client. Especially if you plan to create a fairly extensive website with many functions that are based on graphql api. As for On-demand Incremental Static Regeneration, both Apollo and urql handle that flawlessly. However, if I had to choose, it would definitely be urql. Works great, easy to implement, easy to migrate from Apollo, fast and small, but most importantly, well documented and heavily developed. Good luck. cc: @bebjakub |
Beta Was this translation helpful? Give feedback.
-
Hi, next.js 12.1 introduces On-demand Incremental Static Regeneration.
"Next.js now exposes a function unstable_revalidate () allowing you to revalidate individual pages that use getStaticProps. (...) You can now manually purge the Next.js cache for a specific page on-demand."
This gives the possibility to trigger the revalidate cache of selected paths, e.g. during publishing, saving and updating (WordPress backend) without the need to set revalidation for a specific time. With larger websites this will save a lot of server resources while still maintaining excellent performance.
I wonder if you are considering introducing this possibility in future versions of Faust?
More info on next.js On-demend ISR: https://nextjs.org/blog/next-12-1
Beta Was this translation helpful? Give feedback.
All reactions