Skip to content

Commit 9d2bfd9

Browse files
authored
fix: temporarily increase the cache hours (anuraghazra#1771)
1 parent 9734a99 commit 9d2bfd9

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

api/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ module.exports = async (req, res) => {
5252
);
5353

5454
const cacheSeconds = clampValue(
55-
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
56-
CONSTANTS.TWO_HOURS,
55+
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
56+
CONSTANTS.FOUR_HOURS,
5757
CONSTANTS.ONE_DAY,
5858
);
5959

api/pin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ module.exports = async (req, res) => {
4141
const repoData = await fetchRepo(username, repo);
4242

4343
let cacheSeconds = clampValue(
44-
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
45-
CONSTANTS.TWO_HOURS,
44+
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
45+
CONSTANTS.FOUR_HOURS,
4646
CONSTANTS.ONE_DAY,
4747
);
4848

api/top-langs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ module.exports = async (req, res) => {
4848
);
4949

5050
const cacheSeconds = clampValue(
51-
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
52-
CONSTANTS.TWO_HOURS,
51+
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
52+
CONSTANTS.FOUR_HOURS,
5353
CONSTANTS.ONE_DAY,
5454
);
5555

api/wakatime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module.exports = async (req, res) => {
4444
const stats = await fetchWakatimeStats({ username, api_domain, range });
4545

4646
let cacheSeconds = clampValue(
47-
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
48-
CONSTANTS.TWO_HOURS,
47+
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
48+
CONSTANTS.FOUR_HOURS,
4949
CONSTANTS.ONE_DAY,
5050
);
5151

tests/api.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ describe("Test /api/", () => {
144144

145145
expect(res.setHeader.mock.calls).toEqual([
146146
["Content-Type", "image/svg+xml"],
147-
["Cache-Control", `public, max-age=${CONSTANTS.TWO_HOURS}`],
147+
["Cache-Control", `public, max-age=${CONSTANTS.FOUR_HOURS}`],
148148
]);
149149
});
150150

151151
it("should set proper cache", async () => {
152-
const { req, res } = faker({ cache_seconds: 8000 }, data);
152+
const { req, res } = faker({ cache_seconds: 15000 }, data);
153153
await api(req, res);
154154

155155
expect(res.setHeader.mock.calls).toEqual([
156156
["Content-Type", "image/svg+xml"],
157-
["Cache-Control", `public, max-age=${8000}`],
157+
["Cache-Control", `public, max-age=${15000}`],
158158
]);
159159
});
160160

@@ -176,7 +176,7 @@ describe("Test /api/", () => {
176176

177177
expect(res.setHeader.mock.calls).toEqual([
178178
["Content-Type", "image/svg+xml"],
179-
["Cache-Control", `public, max-age=${CONSTANTS.TWO_HOURS}`],
179+
["Cache-Control", `public, max-age=${CONSTANTS.FOUR_HOURS}`],
180180
]);
181181
}
182182

@@ -186,7 +186,7 @@ describe("Test /api/", () => {
186186

187187
expect(res.setHeader.mock.calls).toEqual([
188188
["Content-Type", "image/svg+xml"],
189-
["Cache-Control", `public, max-age=${CONSTANTS.TWO_HOURS}`],
189+
["Cache-Control", `public, max-age=${CONSTANTS.FOUR_HOURS}`],
190190
]);
191191
}
192192
});

0 commit comments

Comments
 (0)