Su Safari Mobile a volte l'application cache creata con il file .manifest
delle nuove API HTML5 non funziona nel modo sperato. Vediamo insieme i problemi più comuni.
Content-Type errato
La prima cosa da verificare è che il vostro file manifest venga servito come text/cache-manifest
. Aggiungete la seguente riga al vostro file .htaccess
(o nella configurazione del server) se il vostro web server non supporta questo tipo di contenuto:
AddType text/cache-manifest .manifest
Estensione del file errata
Su Safari Mobile l'estensione del file manifest deve essere .manifest
. Altre estensioni, come .cache
, vengono ignorate.
Errori HTTP
Assicuratevi che tutti gli elementi elencati nel file manifest vengano reperiti dal browser senza restituire errori HTTP. È sufficiente che un solo file restituisca un errore perché l'intero processo di caching si blocchi.
Aggiornare e ricaricare la cache
La documentazione di Apple afferma che:
Important: You must modify the manifest file to trigger a cache update. Changing the HTML file that declares the manifest has no effect on users returning to your site unless you change the manifest file as well. If the manifest file is unchanged, the HTML file that declares the manifest is loaded directly from the cache.
Questo è un aggiornamento manuale. Si può anche utilizzare JavaScript per questo scopo:
function updateSite(event) {
window.applicationCache.swapCache();
}
window.applicationCache.addEventListener('updateready',
updateSite, false);
Tuttavia:
Note: Using JavaScript to add and remove resources from the application cache is not supported.
La documentazione ufficiale Apple sull'oggetto DOMApplicationCache
può essere reperita in questa pagina.