Skip to content

Commit 553ebdd

Browse files
authored
Revert "In memory cache api pages (#23751)" (#23753)
This reverts commit fc08215.
1 parent 53fc301 commit 553ebdd

1 file changed

Lines changed: 0 additions & 48 deletions

File tree

middleware/render-page.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Page from '../lib/page.js'
55
import { isConnectionDropped } from './halt-on-dropped-connection.js'
66
import { nextApp, nextHandleRequest } from './next.js'
77

8-
const pageCache = new Map()
9-
108
export default async function renderPage(req, res, next) {
119
if (req.path.startsWith('/storybook')) {
1210
return nextHandleRequest(req, res)
@@ -31,45 +29,6 @@ export default async function renderPage(req, res, next) {
3129
// Is the request for JSON debugging info?
3230
const isRequestingJsonForDebugging = 'json' in req.query && process.env.NODE_ENV !== 'production'
3331

34-
// ****** temporary caching measure for holiday spam prevention *********
35-
36-
const isApiPage =
37-
req.context.currentPathWithoutLanguage.includes('rest/reference') ||
38-
req.context.currentPathWithoutLanguage.includes('graphql/reference')
39-
40-
// Serve from the cache if possible
41-
const isCacheable =
42-
// Skip for CI
43-
!process.env.CI &&
44-
// Skip for tests
45-
process.env.NODE_ENV !== 'test' &&
46-
// Skip for HTTP methods other than GET
47-
req.method === 'GET' &&
48-
// Skip for JSON debugging info requests
49-
!isRequestingJsonForDebugging &&
50-
// Only API pages
51-
isApiPage
52-
53-
// don't cache query strings
54-
const originalUrl = req.originalUrl.split('?')[0]
55-
56-
if (isCacheable) {
57-
// Stop processing if the connection was already dropped
58-
if (isConnectionDropped(req, res)) return
59-
60-
const cachedHtml = pageCache.get(originalUrl)
61-
if (cachedHtml) {
62-
// Stop processing if the connection was already dropped
63-
if (isConnectionDropped(req, res)) return
64-
65-
console.log(`Serving from cached version of ${originalUrl}`)
66-
// statsd.increment('page.sent_from_cache')
67-
return res.send(cachedHtml)
68-
}
69-
}
70-
71-
// ****** [end] temporary caching measure for holiday spam prevention *********
72-
7332
// add page context
7433
const context = Object.assign({}, req.context, { page })
7534

@@ -145,12 +104,5 @@ export default async function renderPage(req, res, next) {
145104
// Hand rendering over to NextJS
146105
req.context.renderedPage = context.renderedPage
147106
req.context.miniTocItems = context.miniTocItems
148-
149-
// ****** temporary caching measure for holiday spam prevention *********
150-
if (isCacheable) {
151-
pageCache.set(originalUrl, req.context.renderedPage)
152-
}
153-
// ****** [end] temporary caching measure for holiday spam prevention *********
154-
155107
return nextHandleRequest(req, res)
156108
}

0 commit comments

Comments
 (0)