This question concerns part of an extension that has the user open a local HTML file which is just an empty container into which the extension sends the page HTML, JS, CSS. The user also previously provided the names of local resources–such as images, PDF, HTML, audio, video–stored in a directory in the same origin as the local HTML file, which permits the extension to load and display these files without further permisson. The names of the resource fies are stored in indexedDB but the physical files are on the local disk.
This part works. My question is is there a way to control how the local resources are cached, such that something similar to ‘Cache-Control: no-cache’ could be employed? The objective is to have the browser reload a local resource if the user altered it since it was last cached. Currently, if the user edited a resource without clearing the cache, the previous version is displayed. I’d like to make it such that the user doesn’t have to worry about this.
It appears that HTML meta tags under http-equiv are no longer valid for this purpose and likely would not have worked well anyway for the resource files. I don’t understand whether or not it is possible to add something to an HTTP header by intercepting and altering a web request since I don’t understand if any form of a request is made to load a local HTML page and inject code into it from the extension, and haen’t been able to get a listener to detect one for onBeforeRequest and up and don’t think it ever reaches the point at which the response header can be modified because there won’t be one.
I must’ve been very confused about what takes place regarding the cache and local resources. I put this off for several months as I worked through other issues with this extension and, in coming back to it, was sure that the issue was that I had to use CTRL + R to get a ‘fresh’ load of a local resource if it had been edited; and clicking the refresh/reload button would not work. However, in testing this again now, that does not seem to be true. The local resources don’t appear to be placed in the cache at all; at least the options tab in the browser shows no data in the cache after loading local resources. A click of the refresh/reload button will lead to the edited resource being used.
However, I’d like the edited resource to be loaded if the user edits it and doesn’t reload the page. For example, if HTML containing a local resource is built in a document fragment and added to the page, and then the source is edited and that portion of the page is replaced with a newly built fragment, the browser should load the recently edited file.