Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with my appcache manifest test?

I'm trying to test Appcache manifest:

<?php

// reference: http://diveintohtml5.info/offline.html

header( "Content-Type: text/cache-manifest" );
header( "Cache-Control: max-age=0, private, must-revalidate" );

?>CACHE MANIFEST

# todo

/cachetest/tryme/vid/missouristate

Now this appears to have the right headers in Network inspector, and is linked to at the top of a html file:

<!DOCTYPE html>
<html manifest="/cachetest/cache.manifest/index.php" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

However, there is zero evidence this is actually working. If it were working, it should not show any other items, unless it had a NETWORK * setting in that file, as described here:

Finally, let’s examine the network section. The network section in this cache manifest also has just a single line, a line that contains just a single character (*). This character has special meaning in a network section. It’s called the “online whitelist wildcard flag.” That’s a fancy way of saying that anything that isn’t in the appcache can still be downloaded from the original web address, as long as you have an internet connection. This is important for an “open-ended” offline web application. It means that, while you’re browsing this hypothetical offline-enabled Wikipedia online, your browser will fetch images and videos and other embedded resources normally, even if they are on a different domain. (This is common in large websites, even if they aren’t part of an offline web application. HTML pages are generated and served locally, while images and videos are served from a CDN on another domain.) Without this wildcard flag, our hypothetical offline-enabled Wikipedia would behave strangely when you were online — specifically, it wouldn’t load any externally-hosted images or videos!

This looks like similar web-apps that work offline, though I have to wonder if I have to set up https on localhost or local-ip to get the browser to even recognize it.

I remember seeing something recently about Appcache now requiring https as Serviceworker requires https as well. Is that something I have to set up in test environment for this to work in the latest browsers? Can I change an about:config to use on plain http? Or am I missing something else?

like image 904
NoBugs Avatar asked Oct 25 '15 06:10

NoBugs


People also ask

Which of the following is not a valid section of AppCache manifest?

Which is not the section of manifest? Explanation: If the files are not in cache they come from a list of the files in the network. Cache is the default section.

What is cache manifest file?

The cache manifest file is a simple text file that lists the resources the browser should cache for offline access.

What event is fired by the AppCache object when the cache download is complete?

If there is no updated version of the manifest file on the server, then noupdate is fired. If the browser is downloading the cache for the first time, or if is downloading an updated cache, then this is fired. This is fired for each and every file which is downloaded as part of the AppCache.

What is fallback in application cache?

FALLBACK: An optional section specifying fallback pages if a resource is inaccessible. The first URI is the resource, the second is the fallback used if the network request fails or errors. Both URIs must from the same origin as the manifest file. You can capture specific URLs but also URL prefixes.


1 Answers

Check the following steps to see why your code is not working, then maybe your code will work.

  • you are using php file, but The recommended file extension for manifest files is: ".appcache"
  • if you use .appcache then don't need to set header, browser will get text/cache-manifest header for .appcache extension.
  • in manifest The first line, CACHE MANIFEST, is required. so remove php code from first.
  • CACHE MANIFEST section only get resource like JS, CSS, images etc.. I think the name of the page you entered is incorrect.

And after checking the steps above, the manifest will probably be ready as follows.

name will be : index.appcache

CACHE MANIFEST
# todo
/cachetest/images/1.jpg
/cachetest/css/style.css

NETWORK:
/login.php

FALLBACK:
/html/ /cachetest/offline.html
<!DOCTYPE html>
<html manifest="/cachetest/cache.manifest/index.appcache" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

The names of the list of files are given for example.

like image 199
Bhavik Hirani Avatar answered Oct 24 '22 22:10

Bhavik Hirani