0

I have a 6MB binary file in my AppEngine backed app. I need to get this file to my GWT client to do many computations. I'm trying to avoid doing the computations on the server to save my instance hours quota. But this means I have to get the file to my client somehow.

I also don't want to download it to the app each time the app is opened, that would hurt my appengine outgoing bandwidth quota.

It would be nice to download it once, then have the client somehow store it for use the next time the app is opened.

How to best do this?

A ClientBundle? Use HTML5 Storage? Is this sort of thing just not done, and should I just do the computations on the server and send the result to the client?

aez
  • 2,406
  • 2
  • 26
  • 46
  • Why do you need to do the same computations every time an app is accessed? Can't you do these computations once and only store the results on the client? – Andrei Volgin Sep 30 '12 at 12:44
  • Good question, I should have been clearer. The computations are made up of two parts: some current conditions and inputs from the user, which will change all the time; and this 6MB binary data, which will never change. – aez Sep 30 '12 at 15:16

2 Answers2

1

The most easiest way to permanently cache the file is using application cache.

Another ways is HTML5 Storage (localStorage), but there is 2.5 MB limit. To use more than that amount, you have use IndexedDB (Chrome, Firefox, IE10) and WebSQL (Safari, Opera). A wrapper library like YDN-DB help in this case.

Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83
0

You can use DataResource:

https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle#DataResource

The only problem you face is the file size. Different browsers have different limits - I've seen 5MB and 8MB numbers. If you can compress your file to be under 5MB, you should be fine with most browsers. (By the way, it's an enormous amount of data if it can't be compressed any further.)

Also, you can detect a mobile browser (or offer a different URL for mobile version), and do computations on the server for mobile users.

Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
  • Thanks Andrei. Can you please offer some pseudo-code on how to get at the underlying binary data in my client using GWT? Also, can you comment on whether the client will be smart enough to know that it will only need to download the data once, it's not clear from the link you posted that this is the case. – aez Oct 01 '12 at 10:58
  • You need to tell Appengine to set the right headers on your data file. It's very simple: https://developers.google.com/appengine/docs/java/config/appconfig#Static_Files_and_Resource_Files – Andrei Volgin Oct 01 '12 at 19:45
  • Thanks Andrei. To accept your answer, I think I need to see a line of code showing how to get at the binary data using DataResource. How can it be put into some byte[] or something like that? – aez Oct 07 '12 at 02:24