Skip to content

Commit

Permalink
don't cache on asset not found (#2346)
Browse files Browse the repository at this point in the history
  • Loading branch information
srliao authored Feb 19, 2025
1 parent ab67431 commit 72df55e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/services/assets/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (s *Server) handleNotFound(w http.ResponseWriter) {
w.WriteHeader(http.StatusNotFound)
return
}
w.Header().Set("Cache-Control", "no-cache")
w.WriteHeader(http.StatusOK)
w.Write(data)
}
Expand Down
7 changes: 4 additions & 3 deletions ui/packages/workers/src/preview/handlePreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ export async function handlePreview(
);

response = new Response(resp.body, resp);
response.headers.set("Cache-Control", "max-age=5184000");

event.waitUntil(cache.put(cacheKey, response.clone()));
if (resp.headers.get('Cache-Control') !== 'no-cache') {
response.headers.set('Cache-Control', 'max-age=5184000');
event.waitUntil(cache.put(cacheKey, response.clone()));
}
}

return response;
Expand Down

0 comments on commit 72df55e

Please # to comment.