Skip to content

Commit

Permalink
fix: only cache GET requests with status 200
Browse files Browse the repository at this point in the history
  • Loading branch information
flakey5 committed Nov 14, 2023
1 parent 873e3c1 commit b50fdb9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/handlers/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const getHandler: Handler = async (request, env, ctx, cache) => {
}

// Cache response if cache is enabled
if (shouldServeCache && ![304, 206].includes(response.status)) {
if (shouldServeCache && response.status === 200) {
const cachedResponse = response.clone();

cachedResponse.headers.append('x-cache-status', 'hit');
Expand Down

0 comments on commit b50fdb9

Please sign in to comment.