Hi there,
I’m trying to render an SVG image in a lambda function and cache it in the CDN.
I want to avoid invoking the function for each request. In my testing the function was invoked each time I requested the image even with Cache-Control set.
I understand that I should not expect the function to be called only once, because of the all the nodes Netlify CDN has.
Does Netlify CDN support caching SVG images ? Am I doing something wrong ?
Here is my code :
import React from ‘react’;
import RDS from ‘react-dom/server’;
import Avataaars from ‘avataaars’;
export function handler(event, context, callback) {
const appString = RDS.renderToString(React.createElement(Avataaars, event.queryStringParameters, null));
console.log("Avatar rendered...")
callback(null, {
statusCode: 200,
headers: {
"Content-Type": "image/svg+xml",
"Cache-Control": "public, s-max-age=31536000"
},
body: appString
})
}
Any idea?