I use the Rest API to do my content queries.
First, I fetch the master ref and then the content associated to it.
I use the Incremental Static Generation of Next 13 with a Prismic webhook. I have a status 200 which confirms me that the revalidate is done. In my route /api/revalidate, I take care to recover the ids and urls of the pages to revalidate. On this side it's ok.
The problem comes from the first fetch and the master ref. It seems that Prismic also caches on its side and prevents Next from revalidating. So I never get the last master ref and my content never updates.
1 - Is it possible to disable the cache?
2 - Is it possible to modify the max-age of the cache ?
3 - Is there any other solution or maybe this is not the right problem?
I haven't tried it myself, but I think I'd skip querying the master ref since the endpoint automatically calls the latest version of the API. Also, I think Next.js allows you to purge the cache of a specific page on demand. Isn’t this working already on your end?
That's right, you need to include the ref in each query call. I was curious if you were retrieving the refs from a list of releases, as each release has its unique ref. Here are some responses to your initial questions:
1 You can control the cache duration. You can set the cache control headers in your HTTP response to determine how long the cdn caches the content.
2. Yes, you can modify the cache max-age using the Prismic API by adjusting the cache control headers in your response. Setting a lower max-age value will reduce the cache duration, but it may also increase server load and response times.
3. Another solution is to include a query parameter in the API request to bypass caching. For instance, adding a timestamp parameter to the API request would change the request with each call and prevent the browser from caching the response. This would guarantee that you always receive the most recent data.
While I haven't personally tested this setup, I'd be interesting to see if I can replicate it.