-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache control header missing in response headers (while using nitro.publicAssets) #27412
Comments
|
When you are running If you are generating a static site you will need to configure headers on your site differently, by configuring whatever is serving it. |
Hi and thanks for the reply. I tried different approach and started Nuxt app using When i tried to hook every request/response (using |
I guess the only working way is using export default defineNuxtConfig({
// ...
routeRules: {
'/fonts/**': {
headers: {
'cache-control': `public,immutable,max-age=${60 * 60 * 24 * 365},s-maxage=${60 * 60 * 24 * 365}`,
},
},
},
// ...
} |
@danielroe |
@Irelynx I think your configuration was wrong. Here's a working example: export default defineNuxtConfig({
// the $production alias is not _within_ the nitro config
$production: {
nitro: {
publicAssets: [
{
baseURL: '/fonts',
// if you pass a relative path it is relative from the `~/server` directory
dir: '../public/fonts',
maxAge: 35,
},
],
},
},
}) |
Oh.. Thanks again for your time! |
Environment
Reproduction
Repro link: https://stackblitz.com/edit/github-qlh9as?file=nuxt.config.ts
Build and run in production mode
npm install npm run build && npm run preview
Add second console and execute the following to test:
Describe the bug
I tried to tune cache-control and added the following to my nuxt.config:
But while running in production mode, there are no cache-control headers in response:
Additional context
Also tested on real server using postman (directly, without proxies like Nginx), cache-control was absent too.
Logs
No response
The text was updated successfully, but these errors were encountered: