Skip to content

Commit 099b3f4

Browse files
committed
Use constant development build id
1 parent 6ef39a7 commit 099b3f4

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

server/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,11 @@ export default class Server {
408408
}
409409

410410
handleBuildId (buildId, res) {
411-
if (this.dev) return true
411+
if (this.dev) {
412+
res.setHeader('Cache-Control', 'no-store, must-revalidate')
413+
return true
414+
}
415+
412416
if (buildId !== this.renderOpts.buildId) {
413417
return false
414418
}
@@ -428,13 +432,17 @@ export default class Server {
428432
}
429433

430434
handleBuildHash (filename, hash, res) {
431-
if (this.dev) return
435+
if (this.dev) {
436+
res.setHeader('Cache-Control', 'no-store, must-revalidate')
437+
return true
438+
}
432439

433440
if (hash !== this.buildStats[filename].hash) {
434441
throw new Error(`Invalid Build File Hash(${hash}) for chunk: ${filename}`)
435442
}
436443

437444
res.setHeader('Cache-Control', 'max-age=365000000, immutable')
445+
return true
438446
}
439447

440448
send404 (res) {

server/render.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ async function doRender (req, res, pathname, query, {
9393
}
9494

9595
const docProps = await loadGetInitialProps(Document, { ...ctx, renderPage })
96-
// While developing, we should not cache any assets.
97-
// So, we use a different buildId for each page load.
98-
// With that we can ensure, we have unique URL for assets per every page load.
99-
// So, it'll prevent issues like this: https://git.io/vHLtb
100-
const devBuildId = Date.now()
10196

10297
if (res.finished) return
10398

@@ -107,7 +102,7 @@ async function doRender (req, res, pathname, query, {
107102
props,
108103
pathname,
109104
query,
110-
buildId: dev ? devBuildId : buildId,
105+
buildId,
111106
buildStats,
112107
assetPrefix,
113108
nextExport,

0 commit comments

Comments
 (0)