开发者

Serving AppEngine static files

开发者 https://www.devze.com 2023-04-09 01:39 出处:网络
What is the best way to serve static image and javascript files using appengine? From what I can see there are two methods applicable, having the files stored in the war directory of the service you

What is the best way to serve static image and javascript files using appengine?

From what I can see there are two methods applicable, having the files stored in the war directory of the service you are uploading, at design time. The alternative being using the blobstore, with the files开发者_StackOverflow中文版 being uploaded after the service has.

I see there is a 150mb restriction on the resource files in the war directory (with a 10mb limit per file), but from what I can see this is simpler, 'free' space. Is it slower than the blobstore? The dynamic nature of the blobstore is of little interest to me, so the directory seems the better option.

Can anyone offer any advice? Are my conclusions correct?


It's fine to put javascript and images files in your resources file directory on appengine. In my experience, blobstore and resource files have similar performance characteristics.

However, as site speed becomes more important it may make more sense to use a CDN to get the static files to your users more quickly.

If the static javascript is something common like jquery or jquery-ui I would recommend using google libraries API right off the bat: http://code.google.com/apis/libraries/devguide.html


The ideal way to serve static files (image, javascript, css) is to declare them using <static-files> in appengine-web.xml.

The opening paragraph of http://code.google.com/appengine/docs/java/config/appconfig.html#Static_Files_and_Resource_Files lays it out nicely:

Many web applications have files that are served directly to the user's browser, such as images, CSS style sheets, or browser JavaScript code. These are known as static files because they do not change, and can benefit from web servers dedicated just to static content. App Engine serves static files from dedicated servers and caches that are separate from the application servers.


If it is just a normal website, which hosts some images and javascript files, generally it should follow the standard way to put them into the war directory. I cannot see much benefit to put those files into blobstore as you have said no interest to the dynamic nature. Not to mention the another level of complexity you added using blobstore.

0

精彩评论

暂无评论...
验证码 换一张
取 消