I just updated my own add-on in my non-development browser profile. The update was restartless.
When I opened the (html) options panel, text was missing. It was the text that has been added in this version.
Has anyone encountered this issue before? And maybe knows a workaround?
I’m not sure if it’s just the options panel which is affected. I’d love to try the debug button and try it live in javascript, but for some reason, the debug button does not work in firefox 46 (yes the checkbox is enabled).
This is why during development you see many devs attach to url’s loaded + '?' + Math.random()
And then when they move to release, they changed Math.random() to the version number of the addon.
So if old version was 1.0 it would have been this:
+ '?v1.0
And then after dev releases 2.0 he would change to this:
+ '?v2.0'
This way it bypasses only once for the new version. And during development it bypasses cache everytime.
Here is example of how I do it, I create a global cache_key var:
So although this is a headache to devs, and sometimes a hidden thing. I think it’s a great caching feature, it helps speed up loading things in addons a ton. That’s why I think it’s no fix. It would be nice if it was more visible to devs though somehow, I have no ideas.
That’s a nice trick, but since l10n is done automatically, there is no url I can attach that version to.
Or is there a way to tell it to use a different properties file?
I don’t know how to access Services.strings, as it’s not available by default in my add-on, but I used this to test it:
Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService).flushBundles();
Which at least works in a local situation (me dragging a different xpi file into the browser to install it).
Is there a way to detect when my add-on has been updated, so I can call this?
Yes, that seems to work too.
Which way to flush is to prefer? (for best compatibility)
I’ve seen topics talk about some of these resource paths, which seem to change during Firefox versions.
That essentially depends on coding style in my opinion. Services.jsm been in the same place for a long time as far as I know. And as Services.strings is exactly the same service like you get via Cc there is no difference.
One important difference though, is that by using Services you can restrict your code to only be able to access one part of what is exposed and not like importing Cc giving it access to essentially everything.
To do so you’d make the destructuring assignement even more precise and then use strings directly. You could of course also give it a different name.