Reputation: 11
I would like to use google cloud CDN to host images for my clients. I can not discover and upload all images beforehand, and my clients may request images that are not yet stored on the CDN.
How can I add code to google cloud CDN so that if an asset does not exist yet, I can generate it before sending the HTTP response and thus not returning a 404 ?
My best bet was with google cloud functions, but that seems to be not possible (I don't see triggers linked to google cloud CDN).
Upvotes: 1
Views: 1183
Reputation: 598817
I don't think there is any such integration between Google Cloud Functions and Google Cloud CDN.
There is however an integration between Cloud Functions and Firebase Hosting, precisely for your type of use-case. Since Firebase Hosting also uses a CDN of edge caches, the result would be the same.
The flow would roughly be:
And any future calls for the same URL on the same edge will now skip steps 3-5.
For more on this, see the Firebase Hosting documentation on connecting to Cloud Functions.
Upvotes: 2