views:

592

answers:

2

Sorry for the cryptic title.

I would like to know if the cached files from one iPhone webapp using HTML5's manifest capability, can be made available to another webapp from same domain; as in shared libs of javascript code or common image logos. Anyone?

Thanks,

Greg

A: 

I would guess that if you accessed an identical URL it would look in the cache first, but can't say with any authority. Why not just try it? It may need to be in the manifest of both apps, which might lead to unpredictable results. I would also worry about behavior changing with new versions of Safari.

However, what will work is to use localStorage. You can serialize just about anything and save it in localStorage variables for other webapps from the same domain to use. The only limit is the ±5MB per domain (I think).

Which leads to an important warning:

DO NOT use the same localStorage.variablename in multiple webapps/web pages unless you want to as both apps can change the value. If you do this unintentionally, expect hair pulling support issues.

GeoNomad
hmmm... isn't domain level segregation enforced? I can't believe such a gigantic security hole would be left open...
jldupont
+2  A: 

GeoNomad, localStorage is more for variable data that will change over the course of an app's usage rather than initial load information.

isn't domain level segregation enforced?

Sure is, but there is a handy part of the manifest that lets you cross these borders when explicitly stated.

NETWORK:

# All URLs that start with the following lines

# are whitelisted.

http://example.com/examplepath/

http://www.example.org/otherexamplepath/

From Apple.

As a direct answer to the question, to make information for multiple web apps available to each other just add the same info in each manifest (they won't reload unless it detects the data has changed.)

"Multiple application caches in different application cache groups can contain the same resource, e.g. if the manifests all reference that resource."

From WHATWG

madjester