-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
send longer cache headers by default #1725
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
61db654
tell browsers and downstream caches to cache for 10 mins
chris48s 6b54bf0
set Cache-Control: no-cache, no-store, must-revalidate if maxAge=0
chris48s 806cac9
change the default to 15 mins
chris48s af74b90
set expiry headers based on LONG_CACHE setting
chris48s a9d06bd
only set initial value of LONG_CACHE once
chris48s d6f6d2e
if service category is 'debug', exclude from examples
chris48s 70d9e0d
add servertime badge
chris48s f5e69af
set max-age header with BADGE_MAX_AGE_SECONDS, default 0
chris48s 5619ded
ensure maxAge is always an int
chris48s 30232ff
reset env in afterEach()
chris48s 0b1f846
remove pointless param
chris48s ee69f7a
explain why we send Cache-Control and Expires in a comment
chris48s 4864d21
move and clarify debug services check
chris48s 44ee930
ignore maxAge GET param if less than env.BADGE_MAX_AGE_SECONDS
chris48s bb06708
don't specify default in the docs
chris48s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const BaseService = require('../base'); | ||
|
||
module.exports = class Time extends BaseService { | ||
|
||
async handle() { | ||
return { message: new Date() }; | ||
} | ||
|
||
// Metadata | ||
static get defaultBadgeData() { | ||
return { | ||
label: 'time', | ||
color: 'blue', | ||
}; | ||
} | ||
|
||
static get category() { | ||
return 'debug'; | ||
} | ||
|
||
static get url() { | ||
return { | ||
base: 'servertime', | ||
format: '', | ||
capture: [] | ||
}; | ||
} | ||
|
||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there any reason to set Expires along with Cache-Control: max-age? To my reading of the spec, Cache-Control: max-age takes priority.
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.
It's explained here #1651 (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.
Thanks for that pointer!
From #1651 (comment):
It seems like we're acting on a kind of superstition. It would be great to have an example of a client which does this, or a reliable report that this is true.
I'm fine leaving it in for now, though let's add a reference that stays with the code.
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.
The Cache-Control header was defined as part of the HTTP/1.1 specification would be ignored by any HTTP client which implements the HTTP/1.0 standard but not HTTP/1.1. This is definitely an edge case and we should expect any modern web browser or downstream cache to implement HTTP/1.1 but we can't safely assume that only clients implementing HTTP/1.1 will connect to us. I've added a comment clarifying this.
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.
Thanks for explaining that!