Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

fix: cache fetched docs #1001

Merged
merged 1 commit into from
May 28, 2021
Merged

fix: cache fetched docs #1001

merged 1 commit into from
May 28, 2021

Conversation

crisbeto
Copy link
Member

Currently we fetch a doc every time we need to display it which means that user navigating between two pages will have to request the same information multiple times.

These changes add a caching layer since the information isn't going to change.

Currently we fetch a doc every time we need to display it which means that user navigating between two pages will have to request the same information multiple times.

These changes add a caching layer since the information isn't going to change.
@crisbeto crisbeto requested review from Splaktar and devversion May 28, 2021 05:33
@google-cla google-cla bot added the cla: yes label May 28, 2021
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

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

LGTM. Nice change!

}

const stream = this._http.get(url, {responseType: 'text'}).pipe(shareReplay(1));
return stream.pipe(tap(() => this._cache[url] = stream));
Copy link
Member

Choose a reason for hiding this comment

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

My expertise with RxJS is limited, but is there are a reason to cache the stream in the tap? Is this to avoid caching cases where an initial XHR request failed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was trying to avoid caching a failed request.

@crisbeto crisbeto merged commit 4894877 into angular:master May 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants