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

Fix #634: Simplify service worker caching #682

Merged
merged 4 commits into from
Apr 7, 2017
Merged

Conversation

humphd
Copy link

@humphd humphd commented Apr 3, 2017

This depends on (and currently includes) #637, so that should land first.

I'm switching how we do our service worker cache to not depend on manual intervention to add new files, or remove old ones. What we have now is way to easy to mess up, since I'm pretty much the only person who understands it.

I need to figure out the right way to deal with dist/nls/**/* since this new approach is including all strings for all languages in what we cache, which takes the cache up to 5.31 MB for 192 resources from 3.54 MB for 98 resources (I totally missed dist/nls before, so it's amazing it runs at all!)

README.md Outdated
# Extension Loading

Bramble loads a set of extensions defined in `src/extensions/bramble-extensions.json`. You can
add remove from this list. You can also temporarily disable extensions by using `?disableExtensions`.
Copy link

Choose a reason for hiding this comment

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

I'm not sure what you intended to say here but it currently reads "You can add remove from this list."

README.md Outdated

Bramble loads a set of extensions defined in `src/extensions/bramble-extensions.json`. You can
add remove from this list. You can also temporarily disable extensions by using `?disableExtensions`.
For example, to disable QuickView and CSSCodeHints load Bramble with `?disableExtensions=QuickView,CSSCodeHints` on the URL.
Copy link

Choose a reason for hiding this comment

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

nit: "For example: to [...], load Bramble [...] URL."

Here `path` refers to the path under `src/` where the extension's dir lives.
The optional `copy` array includes file path globs to be used when copying
files from `src/` to `dist/` for this extension at build time. Many extensions
have no external dependencies, other than the `main.js` file and any modules it
Copy link

Choose a reason for hiding this comment

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

nit: looking at bramble-extensions.json file only four out fifteen don't have external dependencies, so it might be better to phrase this as the exception rather than the baseline.

var brambleExtensions = extensionInfo.map(function(info) {
return info.path;
});

if(disableExtensions) {
disableExtensions.split(",").forEach(function (ext) {
Copy link

Choose a reason for hiding this comment

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

would this be better as a filter?

if (disableExtensions) {
  let disabledExtensions = disableExtensions.split(","); // might even be able to safely reassign to disableExtensions
  brambleExtensions = brambleExtensions.filter(function(ext) {
    return disabledExtensions.indexOf(ext) === -1;
  });
}

@humphd humphd requested a review from gideonthomas April 6, 2017 16:44
@humphd
Copy link
Author

humphd commented Apr 6, 2017

This is ready for review. I've dealt with the dist/nls caching, based on advice from people at Google.

@humphd
Copy link
Author

humphd commented Apr 6, 2017

This needs to get rebased and landed after #637, which should go in first.

Copy link

@gideonthomas gideonthomas left a comment

Choose a reason for hiding this comment

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

This works pretty well! One thing I noticed that is not directly related to this patch is that we don't gzip the bramble-sw.js file which we probably should and the fix is simple: just to put the swPrecache grunt task above the compress task in grunt-build-browser-compressed

@gideonthomas
Copy link

Looks like this still needs to be rebased because it has one extra commit - "Fix review issues, rework ?disableExtensions logic"

@humphd humphd merged commit d2ce549 into mozilla:master Apr 7, 2017
@humphd
Copy link
Author

humphd commented Apr 7, 2017

OK, I fixed the compress stuff too. I actually had to compress first, then do the sw cache, and then compress the service worker file; otherwise it caches uncompressed files, which is wrong.

Thanks for the review.

timmoy pushed a commit to timmoy/brackets that referenced this pull request Apr 19, 2017
* Fix mozilla#634: simplify service worker caching

* Rework staticFileGlobs to ignore dist/nls, add runtimeCaching for nls, fonts

* Fix review issues, rework ?disableExtensions logic

* Compress dist/ and bramble-sw.js, call uglify after build-extensions
timmoy pushed a commit to timmoy/brackets that referenced this pull request Apr 20, 2017
* Fix mozilla#634: simplify service worker caching

* Rework staticFileGlobs to ignore dist/nls, add runtimeCaching for nls, fonts

* Fix review issues, rework ?disableExtensions logic

* Compress dist/ and bramble-sw.js, call uglify after build-extensions
Rajat-dhyani pushed a commit to Rajat-dhyani/brackets that referenced this pull request Apr 20, 2017
* Fix mozilla#634: simplify service worker caching

* Rework staticFileGlobs to ignore dist/nls, add runtimeCaching for nls, fonts

* Fix review issues, rework ?disableExtensions logic

* Compress dist/ and bramble-sw.js, call uglify after build-extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants