Skip to content

perf(nuxt): increase static asset maxAge to 1yr#19335

Merged
danielroe merged 1 commit into
mainfrom
perf/static-cache
Feb 28, 2023
Merged

perf(nuxt): increase static asset maxAge to 1yr#19335
danielroe merged 1 commit into
mainfrom
perf/static-cache

Conversation

@danielroe

@danielroe danielroe commented Feb 28, 2023

Copy link
Copy Markdown
Member

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

With new Nitro support for cache rules we cache static assets for 30 days. This falls afoul of the Lighthouse recommended length - see https://developer.chrome.com/docs/lighthouse/performance/uses-long-cache-ttl.

Until the next release, you can opt-in to this behaviour by adding this to your nuxt.config:

export default defineNuxtConfig({
  nitro: {
    publicAssets: [
      {
        baseURL: '/_nuxt',
        maxAge: 31536000,
        dir: '~/.nuxt/dist/client/_nuxt',
      },
    ],
  }
})

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added 3.x 🐛 bug Something isn't working as expected ❗ p4-important Important issue, should be addressed soon ⚡ performance Performance degradation or optimization opportunity labels Feb 28, 2023
@danielroe danielroe requested a review from pi0 February 28, 2023 12:55
@danielroe danielroe self-assigned this Feb 28, 2023
@codesandbox

codesandbox Bot commented Feb 28, 2023

Copy link
Copy Markdown

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@danielroe danielroe merged commit 32f6cb2 into main Feb 28, 2023
@danielroe danielroe deleted the perf/static-cache branch February 28, 2023 13:06
@danielroe danielroe mentioned this pull request Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x 🐛 bug Something isn't working as expected ❗ p4-important Important issue, should be addressed soon ⚡ performance Performance degradation or optimization opportunity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants