These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:11 pm Advanced search

Help with appCache update pls!

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Help with appCache update pls!

Postby isk015 » Fri Jan 28, 2011 3:42 am

Hi all! I am new here but iam really having a hard time using html5, so I hope you guys can help me. :wink:

So here is my basic project to understand Offline App Cache:


- Load a dynamic php manifest (manifest.php)

- In my index.htm I have 3 html things:
1. log div that outputs erything that is happening to me
2. button that updates the manifest.
3. an image (image1.jpg)

- What i want is to test an auto-update engine, wich means: i download everything first time. replace the manifest, replace the image with a diferent one (same name tough).

My problens:
1) my manifest is behaving weird:
Code: Select all
<?

header('Content-Type: text/cache-manifest');

echo "CACHE MANIFEST\n";
echo "./image1.jpg\n";

echo "# r 1 \n";

?>


It works like that fine, BUT If I try to change the last line (# rev 1 \n) to a place bellow the "cache manifest" it stops working! Thats weird..... when i try to load the manifest i get an error triggered by the:

// The manifest returns 404 or 410, the download failed,
// or the manifest changed while the download was in progress.
appCache.addEventListener('error', handleCacheError, false);

2) I want to replace the image after the updateready event triggered.

When I use my code it reloads the cache but the image remains the same even after swapCache. Do i need to do something after swapcache to replace the image on the screen? If the image has the same name doesnt the browser updates the image with the new one cached?

If not, Can someone point me to a code that replaces an old image (previously cached) with another new image (with the same same). I tryed to use the:

Code: Select all
appCache.swapCache();


When I use the swapcache it really change the image in the cache but not on the screen, if i reload the page the image changes.....

Thanks To everyone!
isk015
<h6>
 
Posts: 1
Joined: Fri Jan 28, 2011 3:18 am

Postby BlueBoden » Wed Feb 09, 2011 5:46 am

The content which is cached by rules in the manifest file, will only update if the manifest file has been changed.

One way to do that, would be to simply add a version number in the comment section of the file, and increment that whenever you update some content.
User avatar
BlueBoden
<h4>
 
Posts: 26
Joined: Wed Feb 09, 2011 4:40 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests