Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 cache manifest no cache for html file itself

Tags:

html

index.php:

<html manifest="/cache.manifest">

cache.manifest

CACHE MANIFEST

CACHE:

/img.png
FALLBACK:
/ /offline.html
NETWORK:
*

Everything works great, except that the index.php file itself is fetched to cache (tested in chrome). Can I disable caching for the file specifying the manifest so that only the img.png is cached?

Thanks

like image 906
Baversjo Avatar asked Feb 18 '11 19:02

Baversjo


People also ask

Does HTML file get cached?

Browser caching is a process that involves the temporary storage of resources in web browsers. A visitor's web browser downloads various website resources and stores them in the local drive. These include images, HTML files, and JavaScript files.

How do I stop HTML from caching?

When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.

How does HTML 5 implement application cache?

Application Cache in HTML5: The current version of HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection. Now we can make an offline web application that will run without an internet connection by just creating a manifest file in our application.

What is the purpose of Appcache API in HTML5?

The Application Cache (or AppCache) allows a developer to specify which files the browser should cache and make available to offline users. Your app will load and work correctly, even if the user presses the refresh button while they're offline.


2 Answers

No, the file which references the manifest is always itself cached. From the spec:

The resource that declares the manifest (with the manifest attribute) will always get taken from the cache, whether it is listed in the cache or not, even if it is listed in an online whitelist namespace.

like image 58
robertc Avatar answered Nov 15 '22 22:11

robertc


I had the same problem.

I used an iframe to load a page called 'go_offline.html' this page has the manifest attribute on the html element and some dummy content.

the iframe is hidden using css

this way only the dummy page is cached and all requests are caught by the fallback page in the .manifest file

like image 28
Arney Avatar answered Nov 15 '22 21:11

Arney