Unverified Commit 69ff95f5 authored by Ari Freyr Asgeirsson's avatar Ari Freyr Asgeirsson Committed by GitHub

Wrong index path revalidation timer (#20818)

Hello friends

Ran into this bug on our production site, prerenderManifest stores revalidation info for the index as `"/": { .. }`, but the code tries to access this information as `"/index"`.

This leads to our index page always having s-max-age: 1
parent e6e402e4
......@@ -156,7 +156,9 @@ export class IncrementalCache {
) {
data.isStale = true
}
const manifestEntry = this.prerenderManifest.routes[pathname]
const manifestPath = toRoute(pathname)
const manifestEntry = this.prerenderManifest.routes[manifestPath]
if (data && manifestEntry) {
data.curRevalidate = manifestEntry.initialRevalidateSeconds
......
......@@ -5,7 +5,7 @@ export async function getStaticProps() {
return {
props: { world: 'world', time: new Date().getTime() },
// bad-prop
revalidate: 1,
revalidate: 2,
}
}
......
......@@ -58,7 +58,7 @@ const startServer = async (optEnv = {}) => {
const expectedManifestRoutes = () => ({
'/': {
dataRoute: `/_next/data/${buildId}/index.json`,
initialRevalidateSeconds: 1,
initialRevalidateSeconds: 2,
srcRoute: null,
},
'/blog/[post3]': {
......@@ -521,6 +521,15 @@ const runTests = (dev = false, isEmulatedServerless = false) => {
expect(data.pageProps.post).toBe('post-3')
})
if (!dev) {
it('should use correct caching headers for a revalidate page', async () => {
const initialRes = await fetchViaHTTP(appPort, '/')
expect(initialRes.headers.get('cache-control')).toBe(
's-maxage=2, stale-while-revalidate'
)
})
}
it('should navigate to a normal page and back', async () => {
const browser = await webdriver(appPort, '/')
let text = await browser.elementByCss('p').text()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment