Skip to content
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

Add Cache-Control #9

Merged
merged 4 commits into from Feb 15, 2018
Merged

Add Cache-Control #9

merged 4 commits into from Feb 15, 2018

Conversation

willnode
Copy link
Contributor

Add HTTP Header cache-control so that browsers can cache requests for short time, thus saving bandwidth in the long term.

Also adds CACHE_MAX_AGE optional environment variable in case someone wish to modify that.

@willnode
Copy link
Contributor Author

whoa, the test fail?

index.js Outdated
@@ -74,5 +75,6 @@ fetchRepos();

module.exports = (request, response) => {
controlAccess()(request, response);
response.setHeader("cache-control", cache)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single quotes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

index.js Outdated
@@ -5,6 +5,7 @@ const controlAccess = require('control-access');
const token = process.env.GITHUB_TOKEN;
const username = process.env.GITHUB_USERNAME;
const origin = process.env.ACCESS_ALLOW_ORIGIN;
const cache = "max-age=" + (process.env.CACHE_MAX_AGE || 300);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Template string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done (on etag commit)

single quotes and semicolons
@sindresorhus
Copy link
Owner

sindresorhus commented Jan 16, 2018

You could add ETag too, which has much more effect, especially since the repos are only updates once a day.

https://github.com/jshttp/etag

@sindresorhus sindresorhus merged commit 4ab80e5 into sindresorhus:master Feb 15, 2018
@sindresorhus
Copy link
Owner

Looks good. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants