API cache headers

I am trying to take advantage of as much caching as possible with Prismic’s REST API but I am seeing some strange behavior related to HTTP caching.

I am using the JS SDK with this query

  const section = await api.getByUID('section', 'test-section');

This results in this Network request: https://sean-prismic-demo.cdn.prismic.io/api/v2/documents/search?page=1&pageSize=1&ref={"_tracker"%3A"aYrLbFSk"}&q=[[at(my.section.uid%2C%20"test-section")]]

But the response headers seem to disable caching at all layers (e.g. CDN, browser):

cache-control: max-age=0, no-store
pragma: no-cache

Since Prismic.io uses the master-ref to control versioning, it seems like it should be safe to cache at all layers, so how can I enable this?

Hello @sconnolly!

Thank you for reaching out to us and sorry for the delay. Are you still having this issue, I’m not personally familiar with this issue but if you could give us more details on it we can investigate.

Hi @paulina.gavilan,

What sort of details do you need?

@sconnolly, like, how are you implementing these method and/or share any error logs that you’ve been getting.

I missed to tell you before that we don’t recommend using a caching system as this can cause issues because the master ref is updated every time a document is changed and this can cause websites to break.

@paulina.gavilan as I wrote before, I am implementing with the prismic SDK:

const section = await api.getByUID('section', 'test-section');

I understand the ref may change, so I’m not doing any sort of cacheing on the endpoint used to get the current version of the API, but there are multiple articles like this one from prismic about the immutability of prismic documents, so I would expect documents to be cacheable as long as the proper ref is used.