2
votes

I'm having difficulties understanding if my idea of an image gallery will work as I can't seem to get it working.

What I have:

  1. An Google App Engine running with a simple website that serves products where each product can have images
  2. A Google Storage bucket with 1.000.000's images

What I planned to do: Add a CDN & Load balancer to the Google Storage bucket to serve the images worldwide fast on a subdomain.

Status: This works. At least it serves the images.

Problems: But I have the feeling that the architecture is not right as the Google App Engine can't be put behind the same load balancer & CDN to serve all the static content via this CDN. And I see no way to add the content caching headers. The documentation of Google says I should be able to add cache keys in the loadbalancer config. But I've been 10 times through this config and the back-end bucket config but no luck to find any. Also in the app.yaml of the Google App Engine you can't set this as the images are not servered via the App Engine....

So questions:

  • Is it logical in this setup to have a GAE and a separate load
    balancer with a storage bucket with the images?
  • How do I add cache-control headers to the CDN/bucket config of Google Cloud CDN?
1
Can't you just reference in the GAE-supplied pages the image files by the URLs under which they are already being served by the CDN directly from GCS?Dan Cornilescu
@DanCornilescu, could you please provide a more detailed input on this and post it as an answer? Thank you.Rodrigo C.
It was just a suggestion to try, I'm not 100% certain it would work, but sure...Dan Cornilescu
I left this issue for a while as it will require a different setup and I have other prio's for the project for now. At least I wanted to give an update. Images and all other static documents on GCS at least can get Object Meta Data set. See more here: cloud.google.com/storage/docs/gsutil/addlhelp/… That works. Although re-setting all images was not cheap, nor am I sure if this is still the best solution. You still would say to be able to change the defaults on the cache control on the GCS which would make managing the cache control much much easier.Frank Heinen

1 Answers

1
votes

Assuming that the GCS bucket setup you already have in place allows you to serve an image via the CDN & Load balancer as you desire, let's say on a URL like gs://www.example.com/img.png then handling such request will already include all the required cache control.

If so then in your GAE app-provided pages, instead of referencing an image via a relative path to your site, like <img src="/static/img.png">, which would indeed require handling its own cache management inside the GAE app code, you could simply reference the image via its corresponding URL in the existing CDN setup: <img src="gs://www.example.com/img.png">, with all cache control already included.

Note: I didn't actually try it (I don't have such GCS CDN setup), but I see no reason for which this wouldn't work.