Lengthen cache ttl on 404s
This commit is contained in:
parent
8479400c23
commit
20c4926e13
@ -94,9 +94,7 @@ function searchEntries(tarballStream, entryName, wantsIndex) {
|
|||||||
|
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
|
|
||||||
stream
|
stream.on('data', chunk => chunks.push(chunk)).on('end', () => {
|
||||||
.on('data', chunk => chunks.push(chunk))
|
|
||||||
.on('end', () => {
|
|
||||||
const content = Buffer.concat(chunks);
|
const content = Buffer.concat(chunks);
|
||||||
|
|
||||||
// Set some extra properties for files that we will
|
// Set some extra properties for files that we will
|
||||||
@ -139,6 +137,10 @@ export default function findFile(req, res, next) {
|
|||||||
if (!foundEntry) {
|
if (!foundEntry) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
|
.set({
|
||||||
|
'Cache-Control': 'public, max-age=31536000', // 1 year
|
||||||
|
'Cache-Tag': 'missing, missing-entry'
|
||||||
|
})
|
||||||
.type('text')
|
.type('text')
|
||||||
.send(`Cannot find "${req.filename}" in ${req.packageSpec}`);
|
.send(`Cannot find "${req.filename}" in ${req.packageSpec}`);
|
||||||
}
|
}
|
||||||
@ -158,6 +160,10 @@ export default function findFile(req, res, next) {
|
|||||||
} else {
|
} else {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
|
.set({
|
||||||
|
'Cache-Control': 'public, max-age=31536000', // 1 year
|
||||||
|
'Cache-Tag': 'missing, missing-index'
|
||||||
|
})
|
||||||
.type('text')
|
.type('text')
|
||||||
.send(
|
.send(
|
||||||
`Cannot find an index in "${req.filename}" in ${
|
`Cannot find an index in "${req.filename}" in ${
|
||||||
|
Loading…
x
Reference in New Issue
Block a user