I have seen some concerns about the limited cache on the iPhone. I too
found this of concern.  That as well as the total number of server
calls: over the edge, even 3gs, these can be quite time consuming.  To
the second, I started using 'inline images' base 64 encoded to lessen
the number of server requests.  But of course, this only increases the
size  of the CSS and/or JS files.  Further, I used PHP to concatenate
the application requires js files as well as css files to one js file
and one css file to load: so only two server requests (plus some
miscellaneous like ico, start-page, etc..)  As you can imagine, these
two files can get very large and will be uncache'able on the iPhone.

Or not?

In comes HTML5 and it's local storage feature.  I used local storage
to solve this problem across multiple wabapps originating from my
server. Data saved from one webapp is usable by another webapp from
the same server; and local storage has a much higher file size limit.

So I use this feature as a 'shared library' like functionality. You
can download both webapp files, 1-.js and 1-.css, to the iPhone upon
first webapp requirement and skip the DL for subsequent uses of the
same webapp or any other webapp from the same server.

Viola! Large cached webapp shared files; .js, .css, data, whatever...

Here  is a quickie:
-------------------

var str, tmp = '<scr'+'ipt src="jquery-1.3.2.js" type="text/
javascript" charset="utf-8"></scr'+'ipt>';
if ( typeof(localStorage) !== 'object') {
    console.log('Load remote: Local storage not supported.');
} else if ((str=localStorage.getItem('jQuery132JS')) && str.length ) {
    tmp = '<scr'+'ipt type="text/javascript">'+str+'</scr'+'ipt>';
    console.log('Load local.');
} document.write(tmp);

-------------------

Additionally, you can add some shared-lib version control to reload
and resave the files should you need without user intervention.

Good luck.


Greg
-- 
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en.


Reply via email to