Skip to content

Commit 1777d23

Browse files
authored
Merge pull request #18182 from github/repo-sync
repo sync
2 parents f9a1e4a + 17301a4 commit 1777d23

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

middleware/cache-full-rendering.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ export default async function cacheFullRendering(req, res, next) {
9595
// and the NextJS data requests. These are not dependent on the
9696
// request cookie, so they're primed for caching in the CDN.
9797
const ct = res.get('content-type')
98-
if (ct.startsWith('text/html')) {
98+
// We also don't want to bother caching this if it doesn't
99+
// appear to be a NextJS HTML output with
100+
// its `<script id="__NEXT_DATA__">` tag.
101+
if (ct.startsWith('text/html') && body.includes('__NEXT_DATA__')) {
99102
const $ = cheerio.load(body)
100103
const headers = res.getHeaders()
101104
cheerioCache.set(key, [$, headers])

0 commit comments

Comments
 (0)