Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Cache only strategy #251

Merged
merged 1 commit into from
Oct 5, 2016
Merged

Conversation

delapuente
Copy link
Contributor

No description provided.

@mention-bot
Copy link

@delapuente, thanks for your PR! By analyzing the annotation information on this pull request, we identified @darkwing, @brendandahl and @digitarald to be potential reviewers


## Solution
Add static content during the installation of the service worker and use the
cache to retrieve it whether there were network or not.
Copy link

Choose a reason for hiding this comment

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

I think "whether the network is available or not" would sound a bit more idiomatic

<body>
<h1>Cache only</h1>
<img src="./asset" alt="sample asset" />
<p>This image request originates from a controlled page so the image will
Copy link

Choose a reason for hiding this comment

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

What does a "controlled page" mean? Is it a page under the service worker scope? (maybe it'd be better to describe it like that?)

@@ -0,0 +1,45 @@
// Register the ServiceWorker limiting its action to those URL starting
Copy link

Choose a reason for hiding this comment

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

what about "limiting its scope of action", or "limiting its scope"?

</style>
</head>
<body>
<h1>Always synchronized</h1>
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 'synchronized' works here, perhaps 'always fresh from the server' would be more clear. Synchronized makes me think of synchronising content both ways and that's not what's happening...

@@ -0,0 +1,34 @@
var CACHE = 'cache-only';

// On install, cache some resource.
Copy link

Choose a reason for hiding this comment

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

some resources

});

// Open a cache and use `addAll()` with an array of assets to add all of them
// to the cache. Extend the installation until all the assets are saved.
Copy link

Choose a reason for hiding this comment

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

what does 'extend the installation' mean? do you mean the installation isn't finished until the assets are saved to the cache?

});
}

// As simple as opening the proper cache and search for the requested resource.
Copy link

Choose a reason for hiding this comment

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

"simple" is very relative. I'd suggest rewriting this comment as something like 'We will open the cache where we stored the data before, and search for the requested resource'

}

// As simple as opening the proper cache and search for the requested resource.
// Notice in case of no matching, undefined is passed.
Copy link

Choose a reason for hiding this comment

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

'returned', rather than 'passed'

@delapuente
Copy link
Contributor Author

@sole done. I though your comments will dissapear or shown as obsolete but they did not. Anyway, the las commit made the changes.

<iframe src="./non-controlled.html" id="reference"></iframe>
<iframe src="./controlled.html" id="sample"></iframe>
</div>
<p>The images in these iframes points to the same asset in the server. But the first is controlled by the service worker and the second is not.</p>
Copy link

Choose a reason for hiding this comment

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

*point

var referenceIframe = document.getElementById('reference');
var sampleIframe = document.getElementById('sample');

// Fix heights every time the iframe reload.
Copy link

Choose a reason for hiding this comment

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

*"is reloaded" or "reloads" ?

@delapuente delapuente merged commit cde3d26 into mdn:master Oct 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants