Skip to content

Commit

Permalink
perf: check isNextFont only in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pacexy committed Jan 4, 2024
1 parent 663a1ee commit 29d8c0e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/next/src/server/lib/router-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { DevBundlerService } from './dev-bundler-service'
import { type Span, trace } from '../../trace'

const debug = setupDebug('next:router-server:main')
const isNextFont = (pathname: string | null) =>
pathname && /\/media\/[^/]+\.(woff|woff2|eot|ttf|otf)$/.test(pathname)

export type RenderServer = Pick<
typeof import('./render-server'),
Expand Down Expand Up @@ -396,10 +398,7 @@ export async function initialize(opts: {
!res.getHeader('cache-control') &&
matchedOutput.type === 'nextStaticFolder'
) {
const isNextFont =
parsedUrl.pathname &&
/\/media\/[^/]+\.(woff|woff2|eot|ttf|otf)$/.test(parsedUrl.pathname)
if (opts.dev && !isNextFont) {
if (opts.dev && !isNextFont(parsedUrl.pathname)) {
res.setHeader('Cache-Control', 'no-store, must-revalidate')
} else {
res.setHeader(
Expand Down

0 comments on commit 29d8c0e

Please sign in to comment.