Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dynamic js and map files from appcache (app.manifest) #9434

Merged
merged 2 commits into from Dec 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/appcache/appcache-server.js
Expand Up @@ -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/') &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URL prefix may change after #9439, which makes these URLs look like /__browser/dynamic/... but that's OK—this is mostly a note to myself to update this code in that PR.

resource.url.endsWith('.map'))
}

WebApp.addHtmlAttributeHook(function (request) {
if (browserDisabled(request))
return null;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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;
}
});
Expand Down