1

I am using Google App Engine (GAE) to serve an image from Google Cloud Storage (GCS) via the method CloudStorageTools::getImageServingUrl().

This returns an image URL like:

https://lh3.googleusercontent.com/KE4x0Ptk8GbqkCqEcdBVkLF0ZpQceXGL1oL6C5be5zHSqpEGI_pceev1SjOFTHh1kj7zbzwHcFfFgh_6gSIA=s1600

This image is not cached in the browser, as it does not return the proper expire/cache headers. I've tried setting the cache headers on the object in GCS:

Cache-control: public, max-age=1296000

...as well as the cache settings for the GAE configuration file app.yaml:

default_expiration: "4d 5h"

... which booth seem to have no impact on have the image is served. Is there any way to control the cache headers for images served through the URL coming from the CloudStorageTools::getImageServingUrl() method?

Thanks!

T

tromtv
  • 91
  • 1
  • 9
  • In the meantime I found this post https://stackoverflow.com/questions/25148567/list-of-all-the-app-engine-images-service-get-serving-url-uri-options which lists many option including "e7" for setting the expiration. In addition it is possible to serve the urls behind a nginx reverse proxy and to add caching headers there. – tromtv Aug 06 '17 at 11:37
  • Here is my answer showing the reverse proxy option: https://stackoverflow.com/questions/42626832/google-app-engine-getimageservingurl-with-download-file-name/45535874#45535874 – tromtv Aug 09 '17 at 09:54

1 Answers1

0

As mentioned in my comment, this is achievable with the "-e31" flag (in this case 31 days). In addition it can be achieved with a nginx reverse proxy setup (usefull if you need more control over the headers). My answer in the post Google App Engine getImageServingUrl with download file name shows an example.

tromtv
  • 91
  • 1
  • 9