How to get caching to work during PhoneGap initial Load

100 views
Skip to first unread message

markdionne

unread,
Mar 19, 2009, 9:28:08 AM3/19/09
to phonegap
Every time I start up my app which is based on PhoneGap, I see from my
server log that all the components (.js, .css and images etc.) get
loaded across the net. When I run from Safari, usually just my
index.php file gets touched. This must be adding to my startup time.
Is there some way to get caching to work?

(At some point when I was debugging, I think caching WAS working. It
was causing trouble because my edited JavaScript files were not
getting loaded and I think I did something to turn off the caching. I
can't remember what I did.)

PanMan

unread,
Mar 19, 2009, 12:18:09 PM3/19/09
to phonegap
Not a direct answer to your question, but you can offcourse make the
whole application run offline, by placing it on your server.
You can request online data with Ajax calls.

CU,
PanMan.

davidroe

unread,
Mar 19, 2009, 1:08:16 PM3/19/09
to phonegap
not sure how a UIWebView handles this, but MobileSafari will not cache
resources larger than 25K, and will therefore always re-load them from
the server.

as pacman suggested, you can make your app offline and place all
resources on the phone itself, only loading dynamic data from the
server.

/dave

markdionne

unread,
Mar 19, 2009, 2:35:06 PM3/19/09
to phonegap
One of the big advantages of having the files on the server is that I
can easily make fixes, and in fact I've been making about 10 fixes per
day.

What would be really cool would be if PhoneGap could look for each
file first on the phone and second on the net. Index.html would start
out on the server, and load foo.js from the phone. When I wanted to
change foo.js, I would just change the reference to foo2.js and let it
look for the new one on the server.

Is this possible?

PanMan

unread,
Mar 21, 2009, 11:42:55 AM3/21/09
to phonegap
You can, but for "on phone" files to work, you have to start as an
offline app.
(although it should be possible to change this).
You can however start with an on-phone index, that redirects to your
web index. (for this you do have to make the change that allows
external sites to work).
Good luck,
PanMan (not Pacman! :P)

markdionne

unread,
Mar 23, 2009, 9:55:56 AM3/23/09
to phonegap
If an on-phone index redirects to the web with <meta http-
equiv="Refresh" ...> I think all the related files (img files for
example) will also be reloaded from the web. Perhaps a frame might
work?

Дмитрий Фролов

unread,
Jun 1, 2009, 11:51:53 AM6/1/09
to phon...@googlegroups.com
It seems like caching does not work even if phonegap is in offline mode with iframe, that points to external site. Any updates on this problem?
Reply all
Reply to author
Forward
0 new messages