Search code examples
htmlfirefoxhtml5-appcachecache-manifest

HTML5 application Cache Firefox is caching the not listed current page


my manifest looks like this :

<?php
header("Cache-Control: no-cache, private");
header("Content-Type: text/cache-manifest");

?>
CACHE MANIFEST
# v32
/wp-content/plugins/sitepress-multilingual-cms/res/css/language-selector.css?v=3.1.9.3
/wp-content/themes/mytheme/css/reset.css
/wp-content/themes/mytheme/js/jquery-2.1.3.min.js
/wp-content/themes/mytheme/img/reset.png
/wp-content/themes/mytheme/img/tablette_petit.png
/wp-content/themes/mytheme/img/ordi_petit.png
/wp-content/themes/mytheme/img/home.png
/wp-content/themes/mytheme/img/update.png
/wp-content/themes/mytheme/font/tahoma2.ttf

FALLBACK:
/ /offline/

the goal is to display the offline page when offine for any page.

This manifest is set when accessing the page :

http://somfy.local/mypage/

<!doctype html>
<?php
$manifest="";
if($pagename == "mypage"){
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false){
        $manifest="manifest=\"/cachemanifest/\"";
    }else{
        $manifest="manifest=\"/cachemanifestothers/\"";
    }
}
//$manifest="";
?>
<html class="mainsite" <?php echo $manifest; ?>>

(chrome has a special manifest because cache is working well)

The problem is that firefox is caching mypage : When I modify it, F5 does nothing until I update the manifest. In about:cache I see every file listed + /mypage. But this page is NOT listed in the CACHE: section.

It is very boring to update the manifest each time I modify this page... And later when I go offline and access /mypage I don't fall back to the /offline page but see /mypage because it is cached and the page is broken because it misses lot of js / css .

Thanks for help


Solution

  • Well it is not a bug it is a feature of application it is called Master entries.

    https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache#Master_entries

    discussed here :

    http://www.webdirections.org/blog/appcache-not-so-much-a-douchebag-as-a-complete-pain-in-the/

    A master entry is an HTML file that includes a manifest attribute in the html element that points to a manifest file (which is the only way to create an HTML5 appcache BTW). Any such HTML file is automatically added to the cache.