views:

208

answers:

2

Is it possible to access Google Chrome's cache from within an extension?

I'd like to write an extension that loads a cached version of a page when the online one can't be accessed (e.g. Internet connectivity issue).

Updated: I know I could write an NPAPI plugin accessible through an extension to accomplish this but I'd rather not suffer writing one... I am after a solution without resorting to NPAPI, please.

Note: as far as I can tell, Google Chrome doesn't support this functionality (at least not out-of-the-box): I just had an episode of "no Internet access" and I was stranded...

A: 

Unfortunately, I'm 99% sure that this is impossible without using an NPAPI in your extension.

Chrome extensions are sandboxed to their own process, and can only access files within the extension's folder.

There is some support for things like chrome://favicon/. But that's about it, at least for now.

Source (Google Chrome Extensions Reference)

Pauan
A: 

P.S. I just had a crazy idea. Extensions only have access to files in their folder... but Chrome stores it's cache in the Cache folder. What you might try is, copy (or move) the Cache folder into a subfolder within the extension. The extension should now be able to access the cache.

Whether this is enough to actually enable offline mode... I don't know. I do see some HTML files (and obviously a lot of images) within my Cache folder, though.

In fact, even without using an extension, I can open up the HTML files in Chrome. And because they're stored on your computer, you should be able to access them even without internet.

P.S. the Cache folder is stored at PATH-TO-CHROME/Default/Cache

P.P.S. there is a way to store an entire webpage and archive it for later use. Check out this extension:

https://chrome.google.com/extensions/detail/mpiodijhokgodhhofbcjdecpffjipkle

Pauan

related questions