Skip to content

Commit

Permalink
fix: include upstream 403 responses in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
esroyo committed Feb 28, 2024
1 parent 1389fa5 commit 54b0e87
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const isNotFound = ({ status }: { status: number }): boolean => {
return status === 404;
};

export const isForbidden = ({ status }: { status: number }): boolean => {
return status === 403;
};

export const calcExpires = (headers: Headers): string => {
const DEFAULT = '600';
const cacheControl = Object.fromEntries(
Expand Down Expand Up @@ -139,7 +143,8 @@ export const createFinalResponse = async (
headers.set('access-control-allow-origin', '*');
}
const isActualRedirect = isRedirect(responseProps) && !isFastPathRedirect;
const isCacheable = isNotFound(responseProps) || isOk(responseProps) ||
const isCacheable = isForbidden(responseProps) ||
isNotFound(responseProps) || isOk(responseProps) ||
isActualRedirect;
const willCache = shouldCache && isCacheable;
if (willCache) {
Expand Down

0 comments on commit 54b0e87

Please sign in to comment.