-
-
Notifications
You must be signed in to change notification settings - Fork 25
Added the ability to have s-maxage cache control headers (alongside existing max-age cache control headers) #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Readme.md
Outdated
| { | ||
| privacy: 'value', | ||
| expiresIn: 300, | ||
| serverExpiresIn: 2592000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an advanced feature and i don't think we should describe it here. Also it's incompatible with privacy: 'value'
plugin.js
Outdated
| value = `${_options.privacy}, max-age=${_options.expiresIn}` | ||
| } | ||
|
|
||
| if (_options.privacy.toLowerCase() === 'public' && _options.serverExpiresIn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (_options.privacy.toLowerCase() === 'public' && _options.serverExpiresIn) { | |
| if (_options.privacy !== undefined && _options.privacy.toLowerCase() === 'public' && _options.serverExpiresIn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Readme.md
Outdated
| resource may be cached. When this is set, and `privacy` is not set to `no-cache`, | ||
| then `', max-age=<value>'` will be appended to the `cache-control` header. | ||
| then `', max-age=<value>'` will be appended to the `cache-control` header. (300 seconds = 5 minutes) | ||
| + `serverExpiresIn` (Default: `undefined`): a value, in seconds, for the *max-age* the resource may be cached on the server. When this is set, and `privacy` is set to `public`, then `', s-maxage=<value>'` will be appended to the `cache-control` header. (2,592,000 seconds = 30 days) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to prefer the explanation from MDN:
The s-maxage response directive also indicates how long the response is fresh for (similar to max-age) — but it is specific to shared caches, and they will ignore max-age when it is present.
Shared caches makes more sense as it's mostly used on CDN edges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to integrate that without copying their language. Let me know what you think
…xample of the object definition, since it's an advanced feature
Fdawgs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition!
jsumners
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
zekth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
Will someone with sufficient permissions merge this? I can't. It's got four approvals. Thanks! |
Added the ability to have s-maxage cache control headers when caching is public, so the length of time something is stored in a CDN can be longer than the length of time it is stored in a browser. e.g. For things stored in AWS CloudFront, https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html#ExpirationDownloadDist
Checklist
npm run testandnpm run benchmarkand the Code of conduct