1
0
mirror of synced 2025-12-21 02:46:50 -05:00
Files
docs/middleware/fast-head.js
Peter Bengtsson 8580fb5e42 fast HEAD requests (#27672)
* fast HEAD requests

* update test
2022-05-13 14:46:57 +00:00

17 lines
427 B
JavaScript

import { cacheControlFactory } from './cache-control.js'
const cacheControl = cacheControlFactory(60 * 60 * 24)
export default function fastHead(req, res, next) {
const { context } = req
const { page } = context
if (page) {
// Since the *presence* is not affected by the request, we can cache
// this and allow the CDN to hold on to it.
cacheControl(res)
return res.status(200).send('')
}
next()
}