Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong index path revalidation timer #20818

Merged
merged 9 commits into from Jan 13, 2021
4 changes: 3 additions & 1 deletion packages/next/next-server/server/incremental-cache.ts
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/integration/prerender/pages/index.js
Expand Up @@ -5,7 +5,7 @@ export async function getStaticProps() {
return {
props: { world: 'world', time: new Date().getTime() },
// bad-prop
revalidate: 1,
revalidate: 2,
}
}

Expand Down
11 changes: 10 additions & 1 deletion test/integration/prerender/test/index.test.js
Expand Up @@ -58,7 +58,7 @@ const startServer = async (optEnv = {}) => {
const expectedManifestRoutes = () => ({
'/': {
dataRoute: `/_next/data/${buildId}/index.json`,
initialRevalidateSeconds: 1,
initialRevalidateSeconds: 2,
srcRoute: null,
},
'/blog/[post3]': {
Expand Down Expand Up @@ -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()
Expand Down