Removing HTML5 Appcache Manifest, Permanently
Asked Answered
H

4

12

I setup an Application Cache on a site and shortly thereafter realized its way more aggressive that I realized. I want to remove it. Permanently.

I've read that passing a changed manifest file, completely empty, with the correct MIMETYPE will remove the cache. Edit: See below. Maurice's answer is the only consistent fix.

Is this the fastest, most effective solution? Is there a better way?

And if you can specify whether or not you've actually used this functionality before with your answer I'd really appreciate it - ambiguous documentation and quirky that didn't show during testing are what got me into this situation.

Highminded answered 11/1, 2012 at 6:51 Comment(0)
H
19

The trick is to first change the manifest URL in your HTML page to something invalid so the browser will receive a 404 when loading it. Make sure to also change the original manifest otherwise the new HTML page is never downloaded. After the browser has failed to download the new manifest URL you can completely remove the manifest setting from the HTML page.

Kind of wacky but that seems to be the only reliable way of removing an existing manifest reference.

Hat answered 11/1, 2012 at 10:10 Comment(4)
So I actually want to set <html manifest="junk-404-link">, not remove the attribute?Highminded
Do that first, and make a change to the original manifest or the page will not be downloaded, and refresh the page. That will break the manifest link and after that you can remove the manifest attribute altogether.Hat
@Hat Does the manifest URL have to be changed, or can the original manifest URL just return a 404 instead?Playmate
Just returning a 404 from the original url should be good enough.Hat
S
9

As of 6/25/2015 I found returning a 404 will not clear the existing appcache for Firefox, and returning a blank appcache will not clear the existing appcache for Chrome. Returning the following appcache seemed to work in IE,Chrome,Safari, and Firefox, although it is unclear by what mechanism the disabling of 'implicit' caching of index.html is accomplished.

NETWORK:
*

CACHE:
FALLBACK:
Syl answered 26/6, 2015 at 22:40 Comment(2)
This should be accepted as as the correct answer. Thanks for sharing this!Ablepsia
The cache must start withCACHE MANIFEST and then a new line to be spec compliant. As for "disabling of 'implicit' caching of index.html", the only solution I know of is to include a hidden iframe, and declare the manifest in the iframe (then the page in the iframe will be cached). I haven't actually tried this, but I read of it as a solution.Atomics
C
4

If you just want it removed from your side you can do that from the Browser. I can only remember how to do it in Chrome. Go to chrome://appcache-internals/ & remove desired file(s). You can also clear cache & cookies & that should work. I've only testing that in Chrome, however.

If you want to remove it for all viewers, I know of no way to detect if they have an old cached version, but I know that keeping the attribute with a false link, like Maurice suggested, would be the only way that I would know; though, I'm sure there is another way, most likely with jQuery.

Cartie answered 26/2, 2014 at 21:5 Comment(1)
The only solution that helped me! Thanks!Maclay
T
2

I've been having a similar issue where I needed to reset the appcache after a failed update (i.e. force a complete removal of the appcache so that it can be re-built from scratch).

Building on Maurice's answer I present the user with a normally hidden link that opens a non-cached page, which just writes a cookie and returns the user to the previous view. This cookie tells the server to return a 404 the next time the appcache is requested, and the user is then taken through the normal login process. When the application next successfully runs it clears the cookie and caching resumes as normal.

Using a cookie in this way gets around issues where the master version of the view is stuck in the appcache, making it difficult to inject a breaking url into manifest="" i.e. the manifest url stays the same, but the server responds with a 404 until told otherwise.

Trepang answered 2/7, 2013 at 20:41 Comment(2)
Interesting. Although if you ultimately want to keep appcache, you can just change the manifest, which will cause the browser to refetch all the assets as if it's starting over. To get rid of the manifest permanently, Maurice was correct.Highminded
My suggestion is really only for apps behind a login, where you can get into difficulties in triggering a successful update using the normal procedures (changing the manifest etc).Trepang

© 2022 - 2024 — McMap. All rights reserved.