don't serve stale server side props from pwa
This commit is contained in:
parent
d4988694c8
commit
d65763ab27
|
@ -1,5 +1,6 @@
|
|||
const { withPlausibleProxy } = require('next-plausible')
|
||||
const withPWA = require('next-pwa')
|
||||
const defaultRuntimeCaching = require('next-pwa/cache')
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'production'
|
||||
const corsHeaders = [
|
||||
|
@ -13,6 +14,21 @@ const corsHeaders = [
|
|||
}
|
||||
]
|
||||
|
||||
console.log([
|
||||
{
|
||||
urlPattern: /\/_next\/data\/.+\/.+\.json$/i,
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'next-data',
|
||||
expiration: {
|
||||
maxEntries: 32,
|
||||
maxAgeSeconds: 24 * 60 * 60 // 24 hours
|
||||
}
|
||||
}
|
||||
},
|
||||
...defaultRuntimeCaching.filter((c) => c.options.cacheName !== 'next-data')
|
||||
])
|
||||
|
||||
// XXX this fragile ... eb could change the version label ... but it works for now
|
||||
const commitHash = isProd
|
||||
? Object.keys(require('/opt/elasticbeanstalk/deployment/app_version_manifest.json').RuntimeSources['stacker.news'])[0].match(/^app-(.+)-/)[1] // eslint-disable-line
|
||||
|
@ -21,7 +37,21 @@ const commitHash = isProd
|
|||
module.exports = withPWA({
|
||||
dest: 'public',
|
||||
register: true,
|
||||
customWorkerDir: 'sw'
|
||||
customWorkerDir: 'sw',
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: /\/_next\/data\/.+\/.+\.json$/i,
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'next-data',
|
||||
expiration: {
|
||||
maxEntries: 32,
|
||||
maxAgeSeconds: 24 * 60 * 60 // 24 hours
|
||||
}
|
||||
}
|
||||
},
|
||||
...defaultRuntimeCaching.filter((c) => c.options.cacheName !== 'next-data')
|
||||
]
|
||||
})(
|
||||
withPlausibleProxy()({
|
||||
env: {
|
||||
|
|
Loading…
Reference in New Issue