Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

How to add a cache policy #9318

Closed
timb-103 opened this issue Nov 25, 2022 · 1 comment
Closed

How to add a cache policy #9318

timb-103 opened this issue Nov 25, 2022 · 1 comment

Comments

@timb-103
Copy link

Environment


  • Operating System: Windows_NT
  • Node Version: v16.14.0
  • Nuxt Version: 3.0.0
  • Nitro Version: 1.0.0
  • Package Manager: npm@8.5.4
  • Builder: vite
  • User Config: app, css, modules, googleFonts, nitro
  • Runtime Modules: @nuxtjs/google-fonts@3.0.0-1
  • Build Modules: -

Reproduction

export default defineNuxtConfig({
  css: ['@/assets/css/global.css'],
  modules: ['@nuxtjs/google-fonts'],

  googleFonts: {
    families: {
      Poppins: [300, 400, 500, 600, 700, 800, 900],
    },
    display: 'swap',
  },

  nitro: {
    compressPublicAssets: true,
  },
})

Describe the bug

Pagespeed insights is telling me to serve static assets with an efficient cache policy, but not sure how to do this in nuxt 3 or if it's possible?

I've added the compressPublicAssets flag to nitro and it does generate the .gz files in the output directory - but when visiting the website it's not loading them as seen in the image below:

image

Additional context

No response

Logs

No response

@bot08
Copy link
Contributor

bot08 commented Nov 25, 2022

export default defineNuxtConfig({
  routeRules: {
    '/_nuxt/**': { headers: { 'cache-control': 's-maxage=86400' } },
  }
})

Something like this?

@nuxt nuxt locked and limited conversation to collaborators Nov 25, 2022
@danielroe danielroe converted this issue into a discussion Nov 25, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants