Created
October 13, 2020 04:21
-
-
Save rained23/769b3e0f8c1fcca292a7ffbf78de783a to your computer and use it in GitHub Desktop.
nextjs cache control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.prepare().then(() => { | |
const server = express(); | |
if (env.NODE_ENV === "production") { | |
server.get( | |
/^\/_next\/static\/(images|fonts)\//, | |
(_, res, nextHandler) => { | |
res.setHeader( | |
"Cache-Control", | |
"public, max-age=31536000, immutable", | |
); | |
nextHandler(); | |
}, | |
); | |
} | |
// ... | |
handle(req, res); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment