mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
Updates
I think proper Cache-Control for frontend now. Fixed the way it handles "home" when purging frontend cache.
This commit is contained in:
parent
d503d65c22
commit
b431d11eba
@ -321,11 +321,15 @@ utilsController.purgeCloudflareCache = async (names, uploads, verbose) => {
|
||||
|
||||
const thumbs = []
|
||||
names = names.map(name => {
|
||||
const url = `${domain}/${name}`
|
||||
const extname = utilsController.extname(name)
|
||||
if (uploads && utilsController.mayGenerateThumb(extname))
|
||||
thumbs.push(`${domain}/thumbs/${name.slice(0, -extname.length)}.png`)
|
||||
return url
|
||||
if (uploads) {
|
||||
const url = `${domain}/${name}`
|
||||
const extname = utilsController.extname(name)
|
||||
if (utilsController.mayGenerateThumb(extname))
|
||||
thumbs.push(`${domain}/thumbs/${name.slice(0, -extname.length)}.png`)
|
||||
return url
|
||||
} else {
|
||||
return name === 'home' ? domain : `${domain}/${name}`
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
|
@ -53,8 +53,9 @@ safe.use(bodyParser.json())
|
||||
|
||||
if (config.cacheControl) {
|
||||
safe.use('/', (req, res, next) => {
|
||||
// max-age: 12 hours (aimed at the HTML pages themselves)
|
||||
res.set('Cache-Control', 'public, max-age=43200, must-revalidate, proxy-revalidate, stale-while-revalidate=86400, stale-if-error=86400')
|
||||
// s-max-age: 30 days (only cache in proxy server)
|
||||
// Obviously we have to purge proxy cache on every update
|
||||
res.set('Cache-Control', 'public, s-max-age=2592000, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800')
|
||||
next()
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user