提交 a7171db2 编写于 作者: J JJ Kasper 提交者: Joe Haddad

Remove previous cache logic (#7794)

* Remove previous cache logic

* Remove old test
上级 a164a70c
......@@ -237,18 +237,6 @@ export async function loadGetInitialProps<
return props
}
// if page component doesn't have getInitialProps
// set cache-control header to stale-while-revalidate
if (ctx.Component && !ctx.Component.getInitialProps) {
const customAppGetInitialProps =
(Component as any).origGetInitialProps &&
(Component as any).origGetInitialProps !== Component.getInitialProps
if (!customAppGetInitialProps && res && res.setHeader) {
res.setHeader('Cache-Control', 's-maxage=86400, stale-while-revalidate')
}
}
if (!props) {
const message = `"${getDisplayName(
Component
......
import App from 'next/app'
export default class MyApp extends App {
static async getInitialProps () {
return {}
}
}
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import {
findPort,
killApp,
nextBuild,
nextStart,
fetchViaHTTP
} from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60
const appDir = join(__dirname, '..')
let appPort
let server
describe('Cache Header', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
server = await nextStart(appDir, appPort)
})
afterAll(() => killApp(server))
it('Does not set cache header with custom getInitialProps in _app', async () => {
const res = await fetchViaHTTP(appPort, '/')
expect(res.headers.get('Cache-Control')).not.toBe(
's-maxage=86400, stale-while-revalidate'
)
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册