I recently started learning RTK Query and I’m now studying how to work with caching. Could someone please suggest the best way to send the Cache-Control header in a request? I’ve seen the following approach in the web, and I’d like to know if it’s correct.
reducerPath: 'exampleApi',
baseQuery: fetchBaseQuery({
baseUrl: '/api',
}),
endpoints: (builder) => ({
getExample: builder.query({
query: () => ({
url: '/example',
headers: {
'Cache-Control': 'no-cache',
},
}),
}),
}),
})```
I haven't tried many options yet, I only found this one, I'm not entirely sure it's the right one.
New contributor
Igor Peterson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.