Storage Configuration
Introduction
Nuxt Skew Protection protects previous build chunks, to do this it uses the temporary storage node_modules/.cache/nuxt/skew-protection by default.
This may not be enough as this will get cleared at lower intervals depending on your CI. To get around this it's recommended to configure a persistent storage driver that works with your platform and deployment workflow.
CDN Usage
Note: If you already are using a CDN with Nuxt that has long cache times and you're not manually purging old assets, you may not need to configure persistent storage.
export default defineNuxtConfig({
app: {
cdnURL: 'https://cdn.example.com' // you may not need persistent storage
}
})
Filesystem Storage
For simplicity, filesystem storage is the easiest to set up. To use it effectively we need to configure our CI
to cache the node_modules/.cache/nuxt/skew-protection folder between builds.
We can do this in GitHub Actions like so:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
# Install dependencies first
- run: npm install
# Cache skew-protection AFTER install, BEFORE build
- name: Cache skew-protection
uses: actions/cache@v4
with:
path: node_modules/.cache/nuxt/skew-protection
key: skew-protection-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
skew-protection-${{ github.ref_name }}-
skew-protection-
# Build step
- run: npm run build
# Deploy step (your deployment method here)
# - run: npm run deploy
Other Storage
The module supports various storage backends via Unstorage.
Cloudflare KV
For Cloudflare Workers, Pages, and NuxtHub deployments, see the dedicated Cloudflare Deployment guide which covers storage configuration in detail.
Redis
export default defineNuxtConfig({
skewProtection: {
storage: {
driver: 'redis',
host: process.env.REDIS_HOST || 'localhost',
port: Number(process.env.REDIS_PORT) || 6379,
password: process.env.REDIS_PASSWORD,
db: 0,
base: 'skew-protection'
}
}
})
Retention Periods
If needed you can control how long versions are kept, by default the configuration is setup for optimal crawler compatibility.
export default defineNuxtConfig({
skewProtection: {
// Keep versions for 45 days
retentionDays: 45,
// Keep maximum 15 versions
maxNumberOfVersions: 15
}
})
Cleanup happens during build, removing:
- Versions older than
retentionDays - Oldest versions beyond
maxNumberOfVersionss