In our application we cache the requests to Prismic and have configured a webhook to clear the caches once there is an update in our repo prismic.
But sometimes the webhook does not work well and we have random errors 403. I suppose that the errors are caused by the fact that we have cached ref and requesting a resource by using an old ref might cause an error 403. Is that right?
Could someone explain exactly how this ref works? I feel that the old ref expires not immediately but in a certain time. During my test, i got a master ref, and then updated a document and published it. The old ref stills worked at the begining and then started provoking 403 errors.
When requesting the prismic document, could we just indicate it is master lastest modification that we wanna instead of precising a referenceId which will expire frequently?
Yes, an old ref can cause a 403 error. There is no way to request the latest content without the latest ref. This is by design. Prismic API calls are optimized as a two-query process. First, you request the latest ref (which is always completely up-to-date), and then you use that ref to fetch the latest content. In Prismic's development kits, like @prismicio/client, every query involves two requests — one for the ref, and another for the content.
I have been told in the past that Prismic caches the past five refs, but I just tested this on my own preview, and found an old ref still working after more than 20 content updates, so I can't say for sure when a ref expires.
I hope this makes sense, but let me know if you have any other questions
Best,
Sam
1 Like
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
4
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.