Skip to content

Commit

Permalink
Serves new appcache from old location
Browse files Browse the repository at this point in the history
When users upgrade from 2.x their old appcache needs to be
updated with new files. This makes sure the appcache is
available at the old location as well as the new location.

This is not a long term solution but will do until we
migrate to using service worker caching instead.

#5247
  • Loading branch information
garethbowen committed Jan 20, 2019
1 parent 675439f commit 1cdffcd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
30 changes: 19 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ const packageJson = require('./package.json'),
releaseName =
process.env.TRAVIS_TAG || process.env.TRAVIS_BRANCH || 'local-development';

const APPCACHE_OPTIONS = {
patterns: [
'build/ddocs/medic/_attachments/manifest.json',
'build/ddocs/medic/_attachments/audio/**/*',
'build/ddocs/medic/_attachments/css/**/*',
'build/ddocs/medic/_attachments/fonts/**/*',
'build/ddocs/medic/_attachments/img/**/*',
'build/ddocs/medic/_attachments/js/**/*',
'build/ddocs/medic/_attachments/xslt/**/*',
],
};

module.exports = function(grunt) {
'use strict';

Expand Down Expand Up @@ -704,18 +716,14 @@ module.exports = function(grunt) {
inbox: {
dest: 'build/ddocs/medic/_attachments/manifest.appcache',
network: '*',
cache: {
patterns: [
'build/ddocs/medic/_attachments/manifest.json',
'build/ddocs/medic/_attachments/audio/**/*',
'build/ddocs/medic/_attachments/css/**/*',
'build/ddocs/medic/_attachments/fonts/**/*',
'build/ddocs/medic/_attachments/img/**/*',
'build/ddocs/medic/_attachments/js/**/*',
'build/ddocs/medic/_attachments/xslt/**/*',
],
},
cache: APPCACHE_OPTIONS,
},
obsolete: {
dest: 'build/ddocs/medic/_attachments/static/dist/manifest.appcache',
network: '*',
baseUrl: '../../',
cache: APPCACHE_OPTIONS,
}
},
sass: {
options: {
Expand Down
1 change: 1 addition & 0 deletions ddocs/medic/rewrites.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{"from": "/img/*", "to": "img/*"},
{"from": "/xslt/*", "to": "xslt/*"},
{"from": "/manifest.appcache", "to": "manifest.appcache"},
{"from": "/static/dist/manifest.appcache", "to": "static/dist/manifest.appcache"},
{"from": "/manifest.json", "to": "manifest.json"},
{"from": "/templates/*", "to": "templates/*"},
{"from": "/", "to": "templates/inbox.html"},
Expand Down
6 changes: 5 additions & 1 deletion webapp/src/js/controllers/inbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,11 @@ var feedback = require('../modules/feedback'),
// to the login page
$log.error('Application cache update error', err);
});
if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {

if (
window.applicationCache.status === window.applicationCache.UPDATEREADY ||
window.applicationCache.status === window.applicationCache.UNCACHED
) {
showUpdateReady();
}
Changes({
Expand Down

0 comments on commit 1cdffcd

Please sign in to comment.