Skip to content

Commit 79f1a6f

Browse files
authored
feat(cache-control): [MC-30] Change max-age to 900 (#59)
1 parent 1a013e3 commit 79f1a6f

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/api/desktop/recommendations/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ router.get(
1616
'/v1/recommendations',
1717
// request must include a consumer
1818
ConsumerKeyHandler,
19-
CacheControlHandler('public, max-age=1800', config),
19+
CacheControlHandler('public, max-age=900', config),
2020
async (req: Request, res: Response, next: NextFunction) => {
2121
try {
2222
const variables = handleQueryParameters(req.query);

src/api/desktop/recommendations/recommendations.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('recommendations API server', () => {
7474
.get(`/desktop/v1/recommendations?${params.toString()}`)
7575
.set(authHeaders)
7676
.send()
77-
.expect('Cache-control', 'public, max-age=1800'); // assert the Cache-control header is overwritten by the /v1/recommendations route
77+
.expect('Cache-control', 'public, max-age=900'); // assert the Cache-control header is overwritten by the /v1/recommendations route
7878

7979
expect(res.status).toEqual(200);
8080

src/api/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ router.use(
1414
WebSessionAuthHandler,
1515
// set Cache-control headers on all routes
1616
// this can be overwritten on downstream routes with another handler
17-
CacheControlHandler('private, max-age=1800', config),
17+
CacheControlHandler('private, max-age=900', config),
1818
// register Desktop sub-router
1919
Desktop
2020
);
@@ -26,7 +26,7 @@ router.use(
2626
WebSessionAuthHandler,
2727
// set Cache-control headers on all routes
2828
// this can be overwritten on downstream routes with another handler
29-
CacheControlHandler('private, max-age=1800', config),
29+
CacheControlHandler('private, max-age=900', config),
3030
// register legacy v3 sub-router
3131
V3
3232
);

src/api/lib/cacheControlHandler.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('CacheControlHandler', () => {
2222
const config = getEnvironmentConfig('development');
2323

2424
const app = express();
25-
app.use(CacheControlHandler('private, max-age=1800', config));
25+
app.use(CacheControlHandler('private, max-age=900', config));
2626
app.get('/', (req, res) => {
2727
res.status(200).json({ yay: true });
2828
});
@@ -36,7 +36,7 @@ describe('CacheControlHandler', () => {
3636
it('sets Cache-control header for other environments', async () => {
3737
const config = getEnvironmentConfig('production');
3838

39-
const headerValue = 'private, max-age=1800';
39+
const headerValue = 'private, max-age=900';
4040

4141
const app = express();
4242
app.use(CacheControlHandler(headerValue, config));
@@ -53,8 +53,8 @@ describe('CacheControlHandler', () => {
5353
it('the closest handler to route implementation sets Cache-control header if multiple exist', async () => {
5454
const config = getEnvironmentConfig('production');
5555

56-
const headerValue1 = 'private, max-age=1800';
57-
const headerValue2 = 'max-age=1800';
56+
const headerValue1 = 'private, max-age=900';
57+
const headerValue2 = 'max-age=900';
5858

5959
const app = express();
6060
app.use(CacheControlHandler(headerValue1, config));

src/api/v3/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ router.get(
1616
'/firefox/global-recs',
1717
// request must include a consumer
1818
ConsumerKeyHandler,
19-
CacheControlHandler('public, max-age=1800', config),
19+
CacheControlHandler('public, max-age=900', config),
2020
async (req: Request, res: Response, next: NextFunction) => {
2121
try {
2222
const variables = handleQueryParameters(req.query);

src/api/v3/recommendations.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('v3 legacy recommendations API server', () => {
6060
const res = await request(app)
6161
.get(`/v3/firefox/global-recs?${params.toString()}`)
6262
.send()
63-
.expect('Cache-control', 'public, max-age=1800'); // assert the Cache-control header is overwritten by the global-recs route
63+
.expect('Cache-control', 'public, max-age=900'); // assert the Cache-control header is overwritten by the global-recs route
6464

6565
expect(res.status).toEqual(200);
6666

0 commit comments

Comments
 (0)