From b1395f67a721375d35a9153246edcd3e1f59e262 Mon Sep 17 00:00:00 2001 From: Kevin Newman Date: Mon, 4 Dec 2017 00:30:58 -0500 Subject: [PATCH 1/2] remove dynamic js and map files from appcache (app.manifest) since they aren't loaded from there by dynamic-imports --- packages/appcache/appcache-server.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/appcache/appcache-server.js b/packages/appcache/appcache-server.js index 66b8f72ea13..a44efdd6427 100644 --- a/packages/appcache/appcache-server.js +++ b/packages/appcache/appcache-server.js @@ -39,6 +39,13 @@ var browserDisabled = function (request) { return disabledBrowsers[request.browser.name]; }; +function isDynamic (resource) { + return resource.type === 'dynamic js' || + (resource.type === 'json' && + resource.url.startsWith('/dynamic/') && + resource.url.endsWith('.map')) +} + WebApp.addHtmlAttributeHook(function (request) { if (browserDisabled(request)) return null; @@ -97,7 +104,8 @@ WebApp.connectHandlers.use(function (req, res, next) { manifest += "/" + "\n"; _.each(WebApp.clientPrograms[WebApp.defaultArch].manifest, function (resource) { if (resource.where === 'client' && - ! RoutePolicy.classify(resource.url)) { + ! RoutePolicy.classify(resource.url) && + !isDynamic(resource)) { manifest += resource.url; // If the resource is not already cacheable (has a query // parameter, presumably with a hash or version of some sort), @@ -127,7 +135,8 @@ WebApp.connectHandlers.use(function (req, res, next) { _.each(WebApp.clientPrograms[WebApp.defaultArch].manifest, function (resource) { if (resource.where === 'client' && ! RoutePolicy.classify(resource.url) && - !resource.cacheable) { + !resource.cacheable && + !isDynamic(resource)) { manifest += resource.url + " " + resource.url + "?" + resource.hash + "\n"; } @@ -162,7 +171,8 @@ var sizeCheck = function () { var totalSize = 0; _.each(WebApp.clientPrograms[WebApp.defaultArch].manifest, function (resource) { if (resource.where === 'client' && - ! RoutePolicy.classify(resource.url)) { + ! RoutePolicy.classify(resource.url) && + !isDynamic(resource)) { totalSize += resource.size; } }); From 13f684c8b528ea93a35d8a6a374d8d5a3a54b1cf Mon Sep 17 00:00:00 2001 From: Kevin Newman Date: Mon, 4 Dec 2017 10:03:25 -0500 Subject: [PATCH 2/2] Apply Meteor code style --- packages/appcache/appcache-server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/appcache/appcache-server.js b/packages/appcache/appcache-server.js index a44efdd6427..fb37f15f4f2 100644 --- a/packages/appcache/appcache-server.js +++ b/packages/appcache/appcache-server.js @@ -39,7 +39,7 @@ var browserDisabled = function (request) { return disabledBrowsers[request.browser.name]; }; -function isDynamic (resource) { +function isDynamic(resource) { return resource.type === 'dynamic js' || (resource.type === 'json' && resource.url.startsWith('/dynamic/') && @@ -105,7 +105,7 @@ WebApp.connectHandlers.use(function (req, res, next) { _.each(WebApp.clientPrograms[WebApp.defaultArch].manifest, function (resource) { if (resource.where === 'client' && ! RoutePolicy.classify(resource.url) && - !isDynamic(resource)) { + ! isDynamic(resource)) { manifest += resource.url; // If the resource is not already cacheable (has a query // parameter, presumably with a hash or version of some sort), @@ -136,7 +136,7 @@ WebApp.connectHandlers.use(function (req, res, next) { if (resource.where === 'client' && ! RoutePolicy.classify(resource.url) && !resource.cacheable && - !isDynamic(resource)) { + ! isDynamic(resource)) { manifest += resource.url + " " + resource.url + "?" + resource.hash + "\n"; } @@ -172,7 +172,7 @@ var sizeCheck = function () { _.each(WebApp.clientPrograms[WebApp.defaultArch].manifest, function (resource) { if (resource.where === 'client' && ! RoutePolicy.classify(resource.url) && - !isDynamic(resource)) { + ! isDynamic(resource)) { totalSize += resource.size; } });