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

Implements cache-then-network requests #195

Merged
merged 3 commits into from
Jan 14, 2015

Conversation

jeffposnick
Copy link
Contributor

@ebidel @wibblymat

Closes #180. IOWA.Request.cacheThenNetwork() isn't used anywhere yet, so the next step will be to try it out for the social feeds (starting with a dummy file under /temporary_api/).

Jake gave the implementation a 👍, for what it's worth.

// a HTTP 204 with an empty body if the request wasn't found in the cache.
if (this.status < 400 && freshContentPending && this.responseText) {
cachedResponse = this.responseText;
cachedContentCallback(JSON.parse(cachedResponse));
Copy link
Contributor

Choose a reason for hiding this comment

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

You would be able to get away with xhr.responseType = 'json' since all browsers that support SW, support that responseType :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather keep it consistent with the XHR for the fresh request, and since IE10 doesn't support responseType, I can't use it there.

@ebidel
Copy link
Contributor

ebidel commented Jan 14, 2015

Reviewed

jeffposnick added a commit that referenced this pull request Jan 14, 2015
Implements cache-then-network requests
@jeffposnick jeffposnick merged commit 95fa592 into google:master Jan 14, 2015
@jeffposnick jeffposnick deleted the cache-then-network branch January 14, 2015 20:10
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.

Implement "Cache, then Network" strategy
2 participants