Click here to Skip to main content
11,432,168 members (52,107 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML5 Offline
Hello Friends,

I am working on a offline Html5 web application. In this i use the HTML5 APPCACHE for offline purpose. I want to handle this cache functionality on user will. Means whenever a user visit this web application he will get the promt msg to change version if he choose to no then this application should work on old version of appcache
(* After refreshing or reloading this web page should work on old version)
Now if user choose yes the his application must use the new version.........


I have search a lot for this put i can only listen the events of this appcache
see this....

http://www.html5rocks.com/en/tutorials/appcache/beginner/[^]

Please if anyone can help me please do it i need it seriously....

Thanks in Advance
Posted 31-Jul-13 20:49pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

1. Browser checks if appcache have been modified on page load. Usually if you have changed only some content in existing files, browser will not detect that cache needs to be reloaded.

2. If you want force updating, use update method of application cache.

window.applicationCache.update()

Important: The update() method only updates the cache—not the web application or anything that is loaded. The easiest way to update the page when the cache is ready is by reloading it:

location.reload();
  Permalink  
Comments
vinu2528 at 1-Aug-13 2:31am
   
Sorry Vyacheslav but this method only work when there is change in appcahe file but i want to update the appcache even if there is no change in appcache file......

And if this cant possible is there any way to stop updating appcahe files by browser even if there is change in appcahe file....
Vyacheslav Voronenko at 1-Aug-13 3:45am
   
Prior writing comment, have you tried code above with activated google chrome developer tools console?
vinu2528 at 1-Aug-13 6:18am
   
ya i already tried all the functions of appcahe like swapcache(),update() all these...
Vyacheslav Voronenko at 1-Aug-13 6:48am
   
My experiments show that it effectively forces cache reload. In addition you might want to introduce some versioning in your cache manifest file (for example calculate hash of all included files, or smth like this) to make sure that in case of any file change manifest file will be definitely updated.

Dirty example:

header('Content-Type: text/cache-manifest');
echo "CACHE MANIFEST\n";

$hashes = "";

$dir = new RecursiveDirectoryIterator(".");
foreach(new RecursiveIteratorIterator($dir) as $file) {
if ($file->IsFile() &&
(pathinfo($file, PATHINFO_EXTENSION)!='appcache') &&
(substr($file->getFilename(), 0, 1) != ".")
)
{
echo $file . "\n";
$hashes .= md5_file($file);
}
}
echo "# Hash: " . md5($hashes) . "\n";
vinu2528 at 5-Aug-13 2:45am
   
First of all Thanks a lot Vyachesiav Voronenko.

But i thing u are not getting my problem.
Now look whenever we changes the cache file our browser download all the new files ok,
Now here is my question come HOW TO ABORT THIS PROCESS when there is some changes in cache file. Means how to call this appcache.Abort() function.

I have used this appcache.abort() ,but it seems it doesnt work.

Hope now you understand my problem
Vyacheslav Voronenko at 5-Aug-13 3:19am
   
If - cache manifest have changed on a server, AND - your single page application is online. - _Why_ do you need to abort that process?
Vyacheslav Voronenko at 5-Aug-13 3:22am
   
Quoting standards:

Once an application is offline it remains cached until one of the following happens:

The user clears their browser's data storage for your site.
The manifest file is modified. Note: updating a file listed in the manifest doesn't mean the browser will re-cache that resource. The manifest file itself must be alternated.
The app cache is programatically updated.


In short: do not modify manifest file - than files will not get updated.

How to update manifest file for each user individually? (i.e. different users - different cache manifests, perhaps staged)

If user visit website first time, his browser loads current manifest, so you might want to use dynamic URL and generate manifest file dynamically:

<html manifest="manifest.php?version=2">

than have your server side to ensure that you update your dynamic manifest file once your user have performed some action to 'update'
vinu2528 at 5-Aug-13 4:15am
   
Soory, Vyacheslav Voronenko but iam making my web application simply in HTML5 and Jquery
How can i dynamically create the appcache file in jquery
Vyacheslav Voronenko at 5-Aug-13 4:32am
   
Appcache is server side part. Perhaps you might want to reread appcache purpose once more - and rethink architecture of your onepage application

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.150428.2 | Last Updated 1 Aug 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100