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

v3: workbox-range-requests module #1108

Merged
merged 3 commits into from
Dec 6, 2017
Merged

v3: workbox-range-requests module #1108

merged 3 commits into from
Dec 6, 2017

Conversation

jeffposnick
Copy link
Contributor

R: @addyosmani @gauntface

Fairly straightforward port of the workbox-range-requests code from v2, with some test changes to accommodate the mocked interfaces, and some additional error messages.

I updated the workbox-sw mapping, but I might be missing some other "meta" things that need to be changed when we add a new library.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 84.757% when pulling 696c8fd on range-requests into 626435d on v3.

Copy link

@gauntface gauntface left a comment

Choose a reason for hiding this comment

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

LGTM. Only nits on descriptions / JSDocs

import './_version.mjs';

/**
* A class implementing the `cachedResponseWillBeUsed` lifecycle callback.

Choose a reason for hiding this comment

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

This description should cover the purpose of the class, not the implementation details.

The range request plugin makes it easy for a Request with a 'range' header to be forfilled by a cached response.
It does this by intercepting the cachedResponseWillBeUsed plugin callback and returning the appropriate subset of the cached Response body.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* @param {Request} options.request The original request, which may or may not
* contain a Range: header.
* @param {Response} options.cachedResponse The complete cached response.
* @return {Promise<Response>} If request contains a Range: header, then

Choose a reason for hiding this comment

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

Nit, could you shorten this to: "If request contains a 'Range' header, then a new Response with status 206 whose body is a subset of cachedResponse is returned, otherwise cachedResponse is returned as-is."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

File Before After Change GZipped
packages/workbox-sw/build/workbox-sw.js 1.43 KB 1.46 KB +2% 792 B

New Files

File Size GZipped
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.66 KB 816 B

All File Sizes

View Table
File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 3.17 KB 3.17 KB 0% 1.34 KB
packages/workbox-broadcast-cache-update/build/workbox-broadcast-cache-update.prod.js 1.05 KB 1.05 KB 0% 565 B
packages/workbox-build/build/_types.js 41 B 41 B 0% 61 B
packages/workbox-build/build/index.js 2.52 KB 2.52 KB 0% 1.06 KB
packages/workbox-cache-expiration/build/workbox-cache-expiration.prod.js 3.13 KB 3.13 KB 0% 1.16 KB
packages/workbox-cacheable-response/build/workbox-cacheable-response.prod.js 593 B 593 B 0% 343 B
packages/workbox-cli/build/app.js 4.57 KB 4.57 KB 0% 1.65 KB
packages/workbox-cli/build/bin.js 2.53 KB 2.53 KB 0% 1.07 KB
packages/workbox-core/build/workbox-core.prod.js 6.67 KB 6.67 KB 0% 2.61 KB
packages/workbox-google-analytics/build/workbox-google-analytics.prod.js 1.94 KB 1.94 KB 0% 985 B
packages/workbox-precaching/build/workbox-precaching.prod.js 4.75 KB 4.75 KB 0% 1.84 KB
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.66 KB 816 B
packages/workbox-routing/build/workbox-routing.prod.js 2.74 KB 2.74 KB 0% 1.23 KB
packages/workbox-strategies/build/workbox-strategies.prod.js 3.22 KB 3.22 KB 0% 1.00 KB
packages/workbox-sw/build/workbox-sw.js 1.43 KB 1.46 KB +2% 792 B
packages/workbox-webpack-plugin/build/index.js 7.29 KB 7.29 KB 0% 2.45 KB

Workbox Aggregate Size Plugin

☠️ WARNING ☠️

We are using 150% of our max size budget.

Total Size: 22.03KB
Percentage of Size Used: 150%

Gzipped: 8.77KB

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 84.757% when pulling 0f7b12b on range-requests into 626435d on v3.

@jeffposnick jeffposnick merged commit af47ff9 into v3 Dec 6, 2017
@jeffposnick jeffposnick deleted the range-requests branch December 6, 2017 21:54
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.

4 participants