Closed Bug 884113 Opened 11 years ago Closed 6 years ago

Request API returns cached version of updated webapp manifest

Categories

(Add-on SDK Graveyard :: General, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: myk, Unassigned)

References

Details

(Whiteboard: [good next bug])

When the Firefox OS Simulator retrieves a webapp manifest for a hosted app from a web server using the Request API, and it previously retrieved the manifest, it returns the cached version of the file, even if the file has changed on the server, although it should return the updated version of the file.

I don't have a reduced testcase, but I tested via the following steps:

1. add http://mykzilla.org/app/manifest.webapp to the Simulator's Dashboard;
2. change name of app in manifest on server;
3. press Update button for app on Dashboard.

Expected Results: name of app changes on Dashboard and in Simulator.

Actual Results: name of app stays the same on Dashboard and in Simulator.

Workarounds include:

1. Load the manifest in a Firefox tab, which correctly retrieves and caches the updated file, before pressing the Update button.

2. Make the URL unique, as recommended by <https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache>, i.e.:

    url: id + '?' + new Date().getTime(), // append microtime to avoid cache

3. Set the "Pragma" request header to "no-cache".

(The Simulator issue tracking this is <https://github.com/mozilla/r2d2b2g/issues/617>.)
Note that `Cache-Control: no-cache` is the HTTP 1.1 way to do `Pragma: no-cache` and also seems to get Firefox to avoid the cache.  Strangely, these headers are supposed to affect proxies and the end server but not Firefox itself.  Nevertheless, they seem to affect Firefox anyway (unless Firefox isn't actually the intermediate that is responsible for this caching problem).

Note that UpdateService sets both headers but also sets the LOAD_BYPASS_CACHE and INHIBIT_CACHING load flags on the XHR channel:

    // Prevent the request from reading from the cache.
    this._request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
    // Prevent the request from writing to the cache.
    this._request.channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;

- <https://github.com/mozilla/mozilla-central/blob/55ec87c57d2027dbe6aa2681c8d855ad8a3977b1/toolkit/mozapps/update/nsUpdateService.js#L3239-L3251>
Whiteboard: [good next bug]
Add-on SDK is no longer supported so resolving bugs as INCOMPLETE
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.