Question

I'm porting an old Java project to GAE. It has some servlets, which generate html pages with static images in them. In the original project these images are stored on the filesystem next to the servlets.

I'm trying to use GCS in the first place, I've uploaded my files and gave permissions on public read. In this case I can reach the files with their public link, I can embed these links into the HTML output. But I have a feeling that this isn't the right solution. The load time seems quite slow, like the images don't "travel internally", and I have to provide permission for every single image.

So my question is, how to get an "internal" URL for a file located on GCS in your GAE application?

I've found some Java examples, but in my case I don't think I need the image object in the source, I just need an URL to pass it on to the HTML source.

As far as I know I could just simple deploy the images with the source as resources, but there are quite many of them.

If there are other soultions, like Datastore, I'm open for that too, but I thought GCS would be the easiest.

Was it helpful?

Solution

Google Cloud Storage is as fast an option for loading images as any other. A browser reads a link and asks the server (in this case GCS) to deliver an image. There is no "internal" URL that can work faster - the speed reflects the bandwidth/distance between GCS and the browser which asked for an image.

You can speed it up by using a CDN, where your image is stored on local servers throughout the world. It only makes sense if you serve content to a very large number of users, and it is a critical part of how fast a page loads.

Another way to speed up page load time is to use image sprites instead of images. This way you cut the number of requests from a browser to a server (i.e. GCS). If you images do not change frequently, and most pages need the same "collection" of images (i.e. not shown dynamically), this is a very good solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top