Merge pull request #419 from spencerwooo/stale-while-revalidate-59

This commit is contained in:
Spencer Woo 2022-02-13 22:13:17 +08:00 committed by GitHub
commit 0fda1c93db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 4 deletions

View file

@ -28,4 +28,8 @@ module.exports = {
// The directLinkRegex is used to match the direct link of the file from the response of the API. We originally use this to prevent
// unauthorised use of the proxied download feature - but that is disabled for now. So you can safely ignore this settings.
directLinkRegex: 'public[.].*[.]files[.]1drv[.]com',
// Cache-Control header, check Vercel documentation for more details.
// https://vercel.com/docs/concepts/edge-network/caching
cacheControlHeader: 'max-age=0, s-maxage=3540, stale-while-revalidate=60'
}

View file

@ -133,7 +133,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// Set edge function caching for faster load times, check docs:
// https://vercel.com/docs/concepts/functions/edge-caching
res.setHeader('Cache-Control', 'max-age=0, s-maxage=600, stale-while-revalidate')
res.setHeader('Cache-Control', apiConfig.cacheControlHeader)
// Sometimes the path parameter is defaulted to '[...path]' which we need to handle
if (path === '[...path]') {

View file

@ -13,7 +13,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// Set edge function caching for faster load times, check docs:
// https://vercel.com/docs/concepts/functions/edge-caching
res.setHeader('Cache-Control', 'max-age=0, s-maxage=600, stale-while-revalidate')
res.setHeader('Cache-Control', apiConfig.cacheControlHeader)
if (typeof id === 'string') {
const itemApi = `${apiConfig.driveApi}/items/${id}`

View file

@ -34,7 +34,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// Set edge function caching for faster load times, check docs:
// https://vercel.com/docs/concepts/functions/edge-caching
res.setHeader('Cache-Control', 'max-age=0, s-maxage=600, stale-while-revalidate')
res.setHeader('Cache-Control', apiConfig.cacheControlHeader)
if (typeof searchQuery === 'string') {
// Construct Microsoft Graph Search API URL, and perform search only under the base directory

View file

@ -17,7 +17,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// Set edge function caching for faster load times, check docs:
// https://vercel.com/docs/concepts/functions/edge-caching
res.setHeader('Cache-Control', 'max-age=0, s-maxage=600, stale-while-revalidate')
res.setHeader('Cache-Control', apiConfig.cacheControlHeader)
// Check whether the size is valid - must be one of 'large', 'medium', or 'small'
if (size !== 'large' && size !== 'medium' && size !== 'small') {