Nuxt caching
Hello, I've just deployed a nuxt app to the server, but it caches in a bad way. in any device, logged in or not, I get one user information, it's cookie and token! I tried to find out what is the problem, I searched and now I think because cache-control: public with max-age=31536000, now I've tried to set it to private or no-cache.
I have two questions:
-
which
cache-controlvalue should I use?privateorno-cache, etc? or even is this problem is because of caching? -
when I try to set headers of axios in
nuxt.config.js, I get this error:
Access to XMLHttpRequest at 'url of the backend' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field cache-control is not allowed by Access-Control-Allow-Headers in preflight response.
I've tried to set Access-Control-Allow-Headers but it did'n work and gives me same error like above, my nuxt.config.js, the axios part is like this:
axios: {
baseURL: 'backend',
headers: {
common: {
'Access-Control-Allow-Headers': 'cache-control',
'cache-control': 'private',
},
},
}
thank you.
Access-Control-Allow-Origin is a response header you need to add this header to the response from your server. More likely you should add cache-control as a response header.
Also checkout Preventing caching on MDN