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

Conversation

3 participants
@willnode
Contributor

willnode commented Jan 16, 2018

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

This comment has been minimized.

Contributor

willnode commented Jan 16, 2018

whoa, the test fail?

index.js Outdated
@@ -74,5 +75,6 @@ fetchRepos();
module.exports = (request, response) => {
controlAccess()(request, response);
response.setHeader("cache-control", cache)

This comment has been minimized.

@SamVerschueren

SamVerschueren Jan 16, 2018

Collaborator

Single quotes

This comment has been minimized.

@willnode

willnode Jan 16, 2018

Contributor

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);

This comment has been minimized.

@SamVerschueren

SamVerschueren Jan 16, 2018

Collaborator

Template string

This comment has been minimized.

@willnode

willnode Jan 16, 2018

Contributor

done (on etag commit)

fix tests fail
single quotes and semicolons
@sindresorhus

This comment has been minimized.

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

willnode added some commits Jan 16, 2018

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sindresorhus

This comment has been minimized.

Owner

sindresorhus commented Feb 15, 2018

Looks good. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment