1
0
mirror of synced 2026-01-11 12:01:47 -05:00
Files
docs/tests/rendering/render-caching.js
Kevin Heis bee3b5c9f3 Enable up to one minute of HTML caching (#29572)
* Enable up to one minute of HTML caching

* Skip a test that isn't the level of cache control we now want
2022-08-03 16:26:53 +00:00

32 lines
1.1 KiB
JavaScript

import { expect, jest, test } from '@jest/globals'
import { get } from '../helpers/e2etest.js'
// import { PREFERRED_LOCALE_COOKIE_NAME } from '../../middleware/detect-language.js'
describe.skip('in-memory render caching', () => {
jest.setTimeout(30 * 1000)
test('second render should be a cache hit', async () => {
// Light mode first
const res1 = await get('/en')
// Because these are effectively end-to-end tests, you can't expect
// the first request to be a cache miss because another end-to-end
// test might have "warmed up" this endpoint.
expect(res1.headers['x-middleware-cache']).toBeTruthy()
const res2 = await get('/en')
expect(res2.headers['x-middleware-cache']).toBeTruthy()
})
test('second render should be cache hit with different __PRIMER_DATA__', async () => {
await get('/en') // first render to assert the next render comes from cache
const res = await get('/en')
expect(res.headers['x-middleware-cache']).toBeTruthy()
// Now do it all over again but with a light color mode
const res2 = await get('/en')
expect(res2.headers['x-middleware-cache']).toBeTruthy()
})
})