Skip to content

Commit

Permalink
Add caching back
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Brown committed Nov 5, 2024
1 parent ca9259c commit 3090e11
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/routes/api/embed/project/[projectUrl]/support.png/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ export const GET: RequestHandler = async ({ url, params }) => {
const buttonOptions = getSupportButtonOptions(url);
// Try to fetch the pre-rendered image from cache
const cacheKey = getCacheKey(buttonOptions, params);
// TODO: re-add
// const cachedImageBase64 = redis && (await redis.get(cacheKey));
// if (cachedImageBase64) {
// const cachedImageBuffer = Buffer.from(cachedImageBase64, 'base64');
// return new Response(cachedImageBuffer, {
// status: 200,
// headers: new Headers({ 'Content-Type': 'image/png' }),
// });
// }
const cachedImageBase64 = redis && (await redis.get(cacheKey));
if (cachedImageBase64) {
const cachedImageBuffer = Buffer.from(cachedImageBase64, 'base64');
return new Response(cachedImageBuffer, {
status: 200,
headers: new Headers({ 'Content-Type': 'image/png' }),
});
}

browser = await puppeteer.launch({
// Dockerfile deployment requires different executablePath
Expand Down

0 comments on commit 3090e11

Please sign in to comment.