View cached Appcache data
Asked Answered
E

1

8

My application is currently using HTML5 appcache.

I want to get the hash of files that I get from update() events. However, I can't seem to find out how to access the resources I downloaded.

I want to do something like

$.get( "/sunflowers.png", function( data ) {
       hash(data)
});

I know that I can view the cached resources via chrome-internals however I hope to automate this process

PS: Bump for chromium devs! please advice.

Ethylene answered 25/2, 2016 at 4:1 Comment(8)
What is your end goal? You could probably use swapCache() after the update is complete and then request the files via ajax. I don't think you can get a list of the individual files that were updated from the browser. You'd had to determine the list of files on your own from the cache manifest or via another method.Donohoe
@RobertHarris I'm unable to access the files with ajax due to cross-origin restrictions, however I know for sure the files have been downloaded by the browser yet I'm unable to access them without chrome-internals.Ethylene
Gotcha. I'm guessing you can't adjust Access-Control-Allow-Origin server side? I guess service workers won't be a viable option either then if you can't make server side changes.Donohoe
you can use an addon to allow it -- chrome.google.com/webstore/detail/allow-control-allow-origi/…Seel
@tasos that a possible method, however it will be hard to get all our users to download the add-on. Could you prove more information on how the addon is accessing AppCache data?Ethylene
i dont know -- you are the one that mentioned unable to access the files with ajax due to cross-origin restrictions -- and thats one way to sort it out. have you tested it yet? as for the users, the cross-origin restrictions are usually down to your domain so if those files are coming from a single domain then you need to register a domain name and use that to get your files via ajaxSeel
if its a CORS issue check the following sites on how to resolve it -- html5rocks.com/en/tutorials/cors -- enable-cors.orgSeel
for clarification, I never solved this. This is not a CORS issue, as I have a hardcoded hash within my webapp. The goal here is to check if the files downloaded by appcache has the same hashes. The main issue for me is that there is no way to access the files downloaded by appcache; you have to trust that Appcache downloaded the right files.Ethylene
S
0

AppCache is effectively deprecated at this point, so it's not likely that the answer for this original use case would still be relevant.

But in general, it's worth pointing out that there's a more "official" way of confirming that the contents of a downloaded subresource match the expected local hashes: using subresource integrity.

Simard answered 15/12, 2020 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.