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.
|
||||
This will only work properly with certain settings in nginx reverse proxy and Cloudflare.
|
||||
Do NOT enable unless you know what you are doing.
|
||||
true: With CDN (Cloudflare)
|
||||
2: When NOT using Cloudflare
|
||||
Enable Cache-Control header tags.
|
||||
Please consult the relevant codes in lolisafe.js to learn the specifics.
|
||||
true or 1: Cloudflare (will cache some frontend pages in CDN)
|
||||
2: Basic Cache-Control without CDNs
|
||||
|
||||
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,
|
||||
|
||||
|
@ -183,15 +183,18 @@ if (config.cacheControl) {
|
||||
next()
|
||||
})
|
||||
|
||||
switch (config.cacheControl) {
|
||||
case 1:
|
||||
case true:
|
||||
// If using CDN, cache public pages in CDN
|
||||
if (config.cacheControl !== 2) {
|
||||
cdnPages.push('api/check')
|
||||
for (const page of cdnPages) {
|
||||
safe.use(`/${page === 'home' ? '' : page}`, (req, res, next) => {
|
||||
safe.get(`/${page === 'home' ? '' : page}`, (req, res, next) => {
|
||||
res.set('Cache-Control', cacheControls.cdn)
|
||||
next()
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
// If serving uploads with node
|
||||
|
Loading…
Reference in New Issue
Block a user