mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
fix: cache-control was set to all frontend pages
this now properly sets only on the specific pages that deserves to be cached in cdn additionally update sample config file to remove warning about cacheControl option this is now mature enough to be simply toggled on/off depending on your own necessity
This commit is contained in:
parent
7c4206a4e2
commit
cb2d7b99f7
@ -708,11 +708,13 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ADVANCED: Use safe.fiery.me-exclusive cache control.
|
Enable Cache-Control header tags.
|
||||||
This will only work properly with certain settings in nginx reverse proxy and Cloudflare.
|
Please consult the relevant codes in lolisafe.js to learn the specifics.
|
||||||
Do NOT enable unless you know what you are doing.
|
true or 1: Cloudflare (will cache some frontend pages in CDN)
|
||||||
true: With CDN (Cloudflare)
|
2: Basic Cache-Control without CDNs
|
||||||
2: When NOT using Cloudflare
|
|
||||||
|
NOTE: If set to Cloudflare, and auth is specified in "cloudflare" option above,
|
||||||
|
lolisafe will automatically call Cloudflare API to purge cache of the relevant frontend pages.
|
||||||
*/
|
*/
|
||||||
cacheControl: false,
|
cacheControl: false,
|
||||||
|
|
||||||
|
21
lolisafe.js
21
lolisafe.js
@ -183,15 +183,18 @@ if (config.cacheControl) {
|
|||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
// If using CDN, cache public pages in CDN
|
switch (config.cacheControl) {
|
||||||
if (config.cacheControl !== 2) {
|
case 1:
|
||||||
cdnPages.push('api/check')
|
case true:
|
||||||
for (const page of cdnPages) {
|
// If using CDN, cache public pages in CDN
|
||||||
safe.use(`/${page === 'home' ? '' : page}`, (req, res, next) => {
|
cdnPages.push('api/check')
|
||||||
res.set('Cache-Control', cacheControls.cdn)
|
for (const page of cdnPages) {
|
||||||
next()
|
safe.get(`/${page === 'home' ? '' : page}`, (req, res, next) => {
|
||||||
})
|
res.set('Cache-Control', cacheControls.cdn)
|
||||||
}
|
next()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// If serving uploads with node
|
// If serving uploads with node
|
||||||
|
Loading…
Reference in New Issue
Block a user