Skip to content

Commit dcab383

Browse files
committed
mend
1 parent fbc3b76 commit dcab383

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

api/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export default async (req, res) => {
6565

6666
res.setHeader(
6767
"Cache-Control",
68-
`public, max-age=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
68+
`max-age=${
69+
cacheSeconds / 2
70+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
6971
);
7072

7173
return res.send(

api/pin.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export default async (req, res) => {
6060

6161
res.setHeader(
6262
"Cache-Control",
63-
`public, max-age=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
63+
`max-age=${
64+
cacheSeconds / 2
65+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
6466
);
6567

6668
return res.send(

api/top-langs.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export default async (req, res) => {
5757

5858
res.setHeader(
5959
"Cache-Control",
60-
`public, max-age=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
60+
`max-age=${
61+
cacheSeconds / 2
62+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
6163
);
6264

6365
return res.send(

api/wakatime.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export default async (req, res) => {
5757

5858
res.setHeader(
5959
"Cache-Control",
60-
`public, max-age=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
60+
`max-age=${
61+
cacheSeconds / 2
62+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
6163
);
6264

6365
return res.send(

tests/api.test.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ describe("Test /api/", () => {
162162
["Content-Type", "image/svg+xml"],
163163
[
164164
"Cache-Control",
165-
`public, max-age=${CONSTANTS.FOUR_HOURS}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
165+
`max-age=${CONSTANTS.FOUR_HOURS / 2}, s-maxage=${
166+
CONSTANTS.FOUR_HOURS
167+
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
166168
],
167169
]);
168170
});
@@ -175,7 +177,9 @@ describe("Test /api/", () => {
175177
["Content-Type", "image/svg+xml"],
176178
[
177179
"Cache-Control",
178-
`public, max-age=${15000}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
180+
`max-age=7500, s-maxage=${15000}, stale-while-revalidate=${
181+
CONSTANTS.ONE_DAY
182+
}`,
179183
],
180184
]);
181185
});
@@ -189,7 +193,9 @@ describe("Test /api/", () => {
189193
["Content-Type", "image/svg+xml"],
190194
[
191195
"Cache-Control",
192-
`public, max-age=${CONSTANTS.ONE_DAY}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
196+
`max-age=${CONSTANTS.ONE_DAY / 2}, s-maxage=${
197+
CONSTANTS.ONE_DAY
198+
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
193199
],
194200
]);
195201
}
@@ -203,7 +209,9 @@ describe("Test /api/", () => {
203209
["Content-Type", "image/svg+xml"],
204210
[
205211
"Cache-Control",
206-
`public, max-age=${CONSTANTS.FOUR_HOURS}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
212+
`max-age=${CONSTANTS.FOUR_HOURS / 2}, s-maxage=${
213+
CONSTANTS.FOUR_HOURS
214+
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
207215
],
208216
]);
209217
}
@@ -216,7 +224,9 @@ describe("Test /api/", () => {
216224
["Content-Type", "image/svg+xml"],
217225
[
218226
"Cache-Control",
219-
`public, max-age=${CONSTANTS.FOUR_HOURS}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
227+
`max-age=${CONSTANTS.FOUR_HOURS / 2}, s-maxage=${
228+
CONSTANTS.FOUR_HOURS
229+
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
220230
],
221231
]);
222232
}

0 commit comments

Comments
 (0)