mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
3 changed files with 44 additions and 25 deletions
@ -0,0 +1,13 @@ |
|||||||
|
// return a middleware to set cache-control header
|
||||||
|
// default period is 30 days
|
||||||
|
export const getCacheMiddleware = (period: string | number = 2592000) => { |
||||||
|
return async (req, res, next) => { |
||||||
|
const { method } = req; |
||||||
|
// only cache GET requests
|
||||||
|
if (method === 'GET') { |
||||||
|
// set cache-control header
|
||||||
|
res.set('Cache-Control', `public, max-age=${period}`); |
||||||
|
} |
||||||
|
next(); |
||||||
|
}; |
||||||
|
}; |
@ -1,5 +1,6 @@ |
|||||||
import { populateMeta } from './populateMeta'; |
import { populateMeta } from './populateMeta'; |
||||||
export * from './columnHelpers'; |
export * from './columnHelpers'; |
||||||
export * from './apiHelpers'; |
export * from './apiHelpers'; |
||||||
|
export * from './cacheHelpers'; |
||||||
|
|
||||||
export { populateMeta }; |
export { populateMeta }; |
||||||
|
Loading…
Reference in new issue