import { Component, OnInit, OnDestroy } from '@angular/core'; import {Http} from "@angular/http"; import { LocalCacheService } from "./local-cache.service"; @Component({ selector: 'app-example', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class ExampleComponent implements OnInit, OnDestroy { constructor(public http:Http, public cache:LocalCacheService){ //Cache an observable let requestObservable = this.http.get("http://example.com/path/to/api").map(res => res.json()) this.cache.observable('my-cache-key', requestObservable, 300).subscribe(result => { //Use result console.log(result) }); } }