Bonjour,

Voila, j’essaie de comprendre avec un exemple simple le CACHE MANIFEST. J'aimerais faire le contrôle de la version du CACHE MANIFEST et recharger le cache si la version a changé. ça me semble assez simple, mais je n'y arrive pas !!

J'ai donc écrit (ou pris à droite et à gauche dans différent tutoriel) le code suivant (ma page status.html):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html manifest="gmas.manifest">
  <head>    
  <meta charset="utf-8" />
  <meta name="generator" content="PSPad editor, www.pspad.com"> 
  <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> 
  <title>appInventaire</title>
 
  <script>
 
 
  function logEvent(a) {
    console.log(a.type);
    switch (a.type)
    {
      case "checking":
          document.getElementById('container').innerHTML = "Vérification...";
      break;
      case "noupdate":
          document.getElementById('container').innerHTML = "Version à jour";
      break;
      case "progress":
          document.getElementById('container').innerHTML = "En cours";  
      break;
      case "downloading":
          document.getElementById('container').innerHTML = "Téléchargement en cours...";
      break;
      case "cached":
          document.getElementById('container').innerHTML = "A jour";
      break;
      case "updateready":
          document.getElementById('container').innerHTML = "Mise à jour installée";
      break;
      case "obsolete":
          document.getElementById('container').innerHTML = "Version obsolete";
      break;
      case "error":
          document.getElementById('container').innerHTML = "Erreur";
      break;
      default:
          document.getElementById('container').innerHTML = "En attente...";
      break;
    } 
    if (a.type == "updateready" || a.type == "cached") {
        window.applicationCache.swapCache();
    }
    if (a.lengthComputable) {
        console.log("total:" + a.total + "  loaded:" + a.loaded);
    }
    if (a.type == "error") {
        window.applicationCache.update();
        document.getElementById('container').innerHTML = "Mise à jour forcée";
 
    }
 
  }  
 
  $(function() {
        if(window.applicationCache){
            window.applicationCache.addEventListener("checking", logEvent, false);
            window.applicationCache.addEventListener("downloading", logEvent, false);
            window.applicationCache.addEventListener("noupdate", logEvent, false);
            window.applicationCache.addEventListener("progress", logEvent, false);
            window.applicationCache.addEventListener("error", logEvent, false);
            window.applicationCache.addEventListener("cached", logEvent, false);
            window.applicationCache.addEventListener("updateready", logEvent, false);
            window.applicationCache.addEventListener("obsolete", logEvent, false);
        }
  });
 
 
  </script>
  <style type="text/css">
 
  #container.default{
    position:absolute;
    right: 2px;
    top: 2px;
    width: 200px;
    height:18px;
    color: #fff;
    padding: 1px 3px;
    background-color: #000; 
    opacity:0.7;
    font-size:13px;
  } 
 
  </style>
  </head>
  <body>
 
 
    <div id="container" class="default">???</div>
  </body>
</html>

mon fichier gmas.manifest :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
CACHE MANIFEST
 
# v1.1 2012-12-03 68
 
status.html
http://code.jquery.com/jquery-latest.min.js
et enfin, mon fichier .htaccess :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
 
AddType text/cache-manifest .appcache
 
 
<IfModule mod_expires.c>
  ExpiresActive on
 
# cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
  ExpiresByType text/cache-manifest       "access plus 0 seconds"
 
  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>
 
</IfModule>
Avec ce code et en utilisant Chrome, les événements 'CHECKING' puis 'DOWNLOADING' sont bien déclenchées.
Par contre avec FF 17, j'ai seulement les événements 'CHECKING' puis 'ERROR' (et seulement ceux là, sans jamais avoir d'autres événements déclenchés)

Je ne comprends pas pourquoi et je ne sais pas comment corriger ce problème.

Par avance merci pour votre aide.
Laurent