Open Saba-Shavidze opened 7 months ago
hi @Saba-Shavidze,
Just to check, do you want to run Cloudfront invalidation from the server function?
I am a little confused by "I run invalidation of /* from console from cloudfront but does not work." as it does take time for the invalidation to propagate but it does invalidate the distribution, so not sure how this didn't work. can you provide some more context how this didn't work
@RJPearson94 For better clarification I will explain my problem. I have strapi for content management, let assume that I added some new products and want to update the cache, I trigger the webhook from strapi which make a post request to the api which is handled by the server function, but is it enough? Or do I need to throw the event to sqs-revalidation queue?
hi @Saba-Shavidze, I think it will depend on how you've built the website, i.e., whether you use ISR or not, but I would say you should call CloudFront and invalidate the cache on either the root '/' or on a specific path. This should allow the new content to be fetched (and cached) in CloudFront. I don't see a need for you to put anything on the queue
@RJPearson94 What is the purpose of the revalidation queue, I was thinking I need to add something there and then revalidate the api cache, otherwise yes I'm updating the cloudfront cache.
The open next docs provide more context on ISR and how it works in open next. The troubleshooting guide provides additional context too https://open-next.js.org/v2/inner_workings/isr https://open-next.js.org/v2/common_issues/isr
So, on demand validation should be done from the code on nextjs side
Question
How can I run revalidation for server function, to get the new products from the endpoint? I run invalidation of
/*
from console fromcloudfront
but does not work. For future, I want to implement the scenario where It could be possible to run revalidation from the admin application.