NuxtN
Nuxt3y ago
Gary

Nitro routeRules shouldInvalidateCache

Not sure I understand how or why but from Nuxt nuxt.config.ts why do the shouldInvalidateCache and shouldBypassCache functions not work?

If I do the following:

  nitro: {
    routeRules: {
      '/**': {
        cache: {
          swr: true,
          maxAge: 60 * 60,
          shouldInvalidateCache: () => true,
          shouldBypassCache: () => true,
        },
      },
    },
  },


<script setup lang="ts">
const time = new Date().getTime()
</script>

<template>
  {{ time }}
</template>


Time never updates until the maxAge expires. I would imagine that cache would be invalidated every time the page loaded.
Was this page helpful?