Using a wildcard in the FALLBACK section of an HTML5 cache manifest file

How to create a stand-alone web application so that when a user visits hxxp: // mywebsite / and is disconnected than hxxp: // mywebsite / offline /. [There are about 100 different dynamic pages on my website, so I cannot transcode them into a cache manifest file]

+3
source share
4 answers
CACHE MANIFEST
CACHE:
/Offline/OfflineIndex.html

FALLBACK:
/ /Offline/OfflineIndex.html

NETWORK:
*

. - , , . , , , . , , html (IE. Synchronize.html), , , cookie localcache. synchronize.html , localcache .

OFFLINE AWESOMENESSSSSSSSSSS!!!!

+5

"manifest.php" "cache.manifest", php :

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

    $hashes = "";

    $dir = new RecursiveDirectoryIterator(".");
    foreach(new RecursiveIteratorIterator($dir) as $file) {
        $info = pathinfo($file);
        if ($file->IsFile() &&
            $file != "./manifest.php" &&
            substr($file->getFilename(), 0, 1) != ".")
        {
            echo $file . "\n";
            $hashes .= md5_file($file);
        }
    }

    echo "# Hash: " . md5($hashes) . "\n";

?>

, - . , :)

+6

, , , . , script .

+1

Link to the manifest file in an invisible iframe on the index page. This way, your index page is not cached, as usual by default, and you have full control over your backups ...

No need for unreliable cookies or localStorage!

0
source

Source: https://habr.com/ru/post/1765121/


All Articles