Temporary storage in the FireFox extension

I have developed an extension that generates a lot * of data during a browsing session. Think 2 - 3 times the total HTTP traffic (images, HTML, etc.).

Currently I'm just writing the whole thing in a Javascript variable, but that obviously doesn't make sense if the extension is going to be of serious use.

So the question is, where should I store this data? It's very rare to get it, but when it's ALL of this. Also, it would be nice if the data is not persisted outside of the current session; stale data is useless in this case, and I would rather not fill the disk unnecessarily.

* Something works in the browser, in Javascript

+2


source to share


3 answers


A fairly standard solution is to use local files as storage. Code executed as a Firefox extension has sufficient privileges to read and write local files. The MDC File I / O Code Snippets page is a very good starting point for understanding and implementing this in your extension. It also shows you how to find your extension directory and illustrates the mechanism for creating temporary files .



These approaches should provide you with the tools you need to complete your tasks. Let us know if you need further questions.

+1


source


You can take a look at the database that ships with Firefox 3.5.



https://developer.mozilla.org/en/Storage

+1


source


On disk. You still won't be able to store everything in memory if it's really 3x traffic. You can always delete unnecessary data at shutdown and / or at the beginning of the next session.

The exact way you store data depends on the specific requirements that you have - what you need to store, what are the data access patterns. If, as you say, you just need to keep separate files, I would save them as files.

0


source







All Articles