Okay, this is from few days back, just have the time to write it.
I'm serving an android installer (.apk) in my Tapestry 5 website. I used asset to do this, its not architectural choice, but its the only thing i knew at the moment. The problem with using my regular approach, form based/Action link. Is that they generate very particular URL. Some android browser requires that the URL Consist of <url>/<filename>.apk so it will be treated as an installer. Thus why the Asset approach.
Couple of days a go. A friend of mine contacted me that he wasn't able to download my apps through his android phone. He keep getting error message about the installer. After couple of messages, i found out the size of the downloaded apps is not the same with the file on the server. And no matter how many times he refresh it he keeps getting the same file. Even when he tried to download from his laptop. He's using his office Wifi, so I asked him if to use GPRS/3G. Seems to fix the problem.
But since a bit tech savvy, he tried the same method using android emulator. Then he send the error message to me. Its about some error chunk size bla.. bla.. proxy bla.. bla.. Turn out that android still having problem with password protected wifi connection. Lesson No 1.
That problem fixed or at least I know about the root cause, I'm interested in finding out the other one. Why he keep receiving the same corrupted installer though he refresh it many times. So finally i have a proper reading about T5 Assets documentation :)
The things you need to know about Assets, since its an asset it have a very specific behavior.Asset is a static content, usually its a static image or css. So it is assumed that Asset rarely changed and expected to exist in deploy time (not dynamic). So if the .apk file didn't exist when the page is rendered, it will show an error page instead the page you want to access. This is happened although the link is not clicked yet.
Another thing about the Asset, is that is have a very long expiration time. The benefit is that the asset will be cached by the browser (and maybe the proxy server ?) for a long time. Giving some performance boost and reduce load for the server. But this also what makes my friend keep receiving the same corrupted installer. That's Lesson number 2, 3 about T5 Asset.
Since I've got time, I find another way to handle this scenario. Turn out this scenario could be handled pretty easy using T5 event link :) Well, learning bit by bit everyday is not a sin right :D
No comments:
Post a Comment