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.
const exampleApi = createApi({
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.