autoupdate.html revision 201ade2fbba22bfb27ae029f4d23fca6ded109a0
1<div id="pageData-name" class="pageData">Autoupdating</div>
2<div id="pageData-showTOC" class="pageData">true</div>
3
4<p>We want extensions to be autoupdated for some of the same reasons as Google Chrome itself: to incorporate bug and security fixes, add new features or performance enhancements, and improve user interfaces.</p>
5
6<p>If you publish your extension using the <a href="https://chrome.google.com/webstore/developer/dashboard">Chrome Developer Dashboard</a>, you can <em>ignore this page</em>. You can use the dashboard to release updated versions of your extension to users, as well as to the Extensions Gallery or Chrome Web Store.</p>
7
8<p>If you want to host your extension somewhere other than the gallery or store, keep reading.
9You should also read <a href="hosting.html">Hosting</a> and
10<a href="packaging.html">Packaging</a>.</p>
11
12
13<h2>Overview</h2>
14<ul><li>An extension manifest may contain an "update_url" for doing update checks.</li>
15<li>The content returned by an update check is an "update manifest" XML document listing the latest version of an extension (or set of extensions, more on that later).</li></ul>
16
17<p>Every few hours, the browser will check if any installed extensions have an autoupdate URL. For each one, it will make a request to that URL looking for an update manifest XML file. If the update manifest mentions a version of an extension that is more recent than what's installed, it will download and install the new version. Similar to manual updates, the new crx must be signed with the same private key as the currently installed version.</p>
18
19
20<h2>Update URL</h2>
21<p>For those who are hosting their own extensions, you need to add the "update_url" key to your <a href="manifest.html">manifest.json</a> file like this:</p>
22
23<pre>{
24  "name": "My extension",
25  ...
26  <b>"update_url": "http://myhost.com/mytestextension/updates.xml"</b>,
27  ...
28}
29</pre>
30
31<h2>Update manifest</h2>
32<p>The "update manifest" returned by the server&nbsp;should be an XML document that looks like this (parts you'll want to modify highlighted):</p>
33
34<pre>
35&lt;?xml version='1.0' encoding='UTF-8'?&gt;
36&lt;gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'&gt;
37  &lt;app appid='<b>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</b>'&gt;
38   &nbsp;&lt;updatecheck&nbsp;codebase='<b>http://myhost.com/mytestextension/mte_v2.crx</b>'&nbsp;version='<b>2.0</b>' /&gt;
39  &lt;/app&gt;
40&lt;/gupdate&gt;
41</pre>
42
43<p>(This XML format is borrowed from that used by Omaha, Google's update infrastructure. See <a href="http://code.google.com/p/omaha/">http://code.google.com/p/omaha/</a> for more details.)</p>
44
45<p><b>appid</b><br>
46The 'appid' property is the extension id, generated based on a hash of the extension's public key as described in <a href="packaging.html">Packaging</a>. You can find out the id of your extension by going to <b>chrome://extensions</b>.</p>
47
48<p><b>codebase</b><br>
49The 'codebase' property is a URL to the crx file.</p>
50
51<p><b>version</b><br>
52This is used by the client to determine whether it should download the crx file at 'codebase'. It should match the version parameter in the crx file's manifest.json file.</p>
53<p>The update manifest XML file may contain information about multiple extensions by including multiple <code>&lt;app&gt;</code> tags.</p>
54
55
56<h2>Testing</h2>
57<p>The default update check frequency is several hours,
58but you can force an update using the Extensions page's
59<b>Update extensions now</b> button.
60</p>
61
62<p>
63Another option is to use the --extensions-update-frequency command-line flag to set a more frequent interval in seconds. For instance, to make checks run every 45 seconds, you would run Google Chrome like this:</p>
64<pre>
65chrome.exe <b>--extensions-update-frequency=45</b></pre>
66
67<p>Note that this affects checks for all installed extensions, so consider the bandwidth and server load implications of this. You may want to temporarily uninstall all but the one extension you are testing with, and should not run with this option turned on during normal browser usage.</p>
68
69
70<h2>Advanced usage: request parameters</h2>
71<p>The basic autoupdate mechanism is designed to make the server-side work as easy as just dropping a static XML file onto any plain webserver such as apache, and updating that XML file as you release new versions of your extension(s).</p>
72<p>More advanced developers may wish to take advantage of the fact that we add on parameters to the request for the update manifest to indicate the extension id and version. Then they can use the same update_url for all of their extensions pointing to a URL running dynamic server side code instead of a static XML file.</p>
73<p>The format of the request parameters is:</p>
74<p><code>&nbsp;&nbsp;?x=&lt;extension_data&gt;</code></p>
75<p>where <code>&lt;extension_data&gt;</code> is an URL-encoded string of the format:</p>
76<p><code>&nbsp;&nbsp;id=&lt;id&gt;&amp;v=&lt;version&gt;</code></p>
77
78<p>So for example, say we have two extensions installed</p>
79<p>&nbsp;&nbsp;Extension 1 with id "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" and version "1.1"<br>
80&nbsp;&nbsp;Extension 2 with id "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" and version "0.4"</p>
81
82<p>and that both point at the same update_url: <code>http://test.com/extension_updates.php</code></p>
83
84<p>The two requests made would be:</p>
85<code>http://test.com/extension_updates.php?x=id%3Daaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%26v%3D1.1</code>
86<br>
87<code>http://test.com/extension_updates.php?x=id%3Dbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb%26v%3D0.4</code>
88
89<p><b>Note</b>: in releases before 3.0.196.x there was a bug in how request parameters were put together (<a href="http://crbug.com/17469" rel="nofollow">http://crbug.com/17469</a>).</p>
90
91<h3>Future work</h3>
92<p>While not implemented yet, we will eventually list multiple extensions in a single request for each unique update_url. For the above example, the request would end up being:</p>
93<p><code>http://test.com/extension_updates.php?x=id%3Daaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%26v%3D1.1&x=id%3Dbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb%26v%3D0.4</code></p>
94
95<p>If the number of installed extensions using the same update_url is large enough that a GET request URL would be too long (probably greater than 1024 characters or so), the update check will instead issue a POST with the request parameters in the POST body.</p>
96
97
98<h2>Advanced usage: minimum browser version</h2>
99<p>As we add more APIs to the extensions system, it's possible you will want to release an updated version of an extension that will only work with newer versions of the browser. While Google Chrome itself is autoupdated, it can take a few days before the majority of the user base has updated to any given new release. To ensure that a given extension update will apply only to Google Chrome versions at or higher than a specific version, you would add the prodversionmin parameter to the <code>&lt;app&gt;</code> tag in your update manifest. For example:</p>
100
101<pre>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
102&lt;gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'&gt;
103&nbsp;&nbsp;&lt;app appid='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'&gt;
104&nbsp;&nbsp; &nbsp;&lt;updatecheck&nbsp;codebase='http://myhost.com/mytestextension/mte_v2.crx'&nbsp;version='2.0' <b>prodversionmin='3.0.193.0'</b>/&gt;
105&nbsp;&nbsp;&lt;/app&gt;
106&lt;/gupdate&gt;
107</pre>
108
109<p>This would ensure that users of this extension would autoupdate to version 2 only if they are running Google Chrome 3.0.193.0 or greater.</p>
110
111