mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added JSDoc to cache control middleware
no-issue
This commit is contained in:
parent
02e4aeccd9
commit
76b33b6e77
1 changed files with 12 additions and 0 deletions
|
@ -8,6 +8,11 @@
|
|||
|
||||
const isString = require('lodash/isString');
|
||||
|
||||
/**
|
||||
* @param {'public'|'private'} profile Use "private" if you do not want caching
|
||||
* @param {object} [options]
|
||||
* @param {number} [options.maxAge] The max-age in seconds to use when profile is "public"
|
||||
*/
|
||||
const cacheControl = (profile, options = {maxAge: 0}) => {
|
||||
const profiles = {
|
||||
public: `public, max-age=${options.maxAge}`,
|
||||
|
@ -20,6 +25,13 @@ const cacheControl = (profile, options = {maxAge: 0}) => {
|
|||
output = profiles[profile];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('express').Request} req
|
||||
* @param {import('express').Response} res
|
||||
* @param {() => void} next
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
return function cacheControlHeaders(req, res, next) {
|
||||
if (output) {
|
||||
res.set({'Cache-Control': output});
|
||||
|
|
Loading…
Reference in a new issue