import {Injectable} from "@angular/core"; import {HttpClient} from "@angular/common/http"; import {properties} from "../../../environments/environment"; @Injectable({ providedIn: 'root' }) export class ClearCacheService { constructor(private http: HttpClient) {} clearCache(message: string = null) { if(properties.deleteCacheUrl) { this.http.get(properties.deleteCacheUrl).subscribe( res => console.log((message ? message + ": " : "") + "Cache cleared!"), err => console.log((message ? message + ": " : "") + "Cache could not be cleared ", err) ); } } purgeBrowserCache(message: string = null, pid: string) { if(properties.deleteBrowserCacheUrl) { let url = properties.deleteBrowserCacheUrl.replace("{pid}", pid); this.http.get(url).subscribe( res => console.log((message ? message + ": " : "") + "Browser Cache purged!"), err => console.log((message ? message + ": " : "") + "Browser Cache could not be purged ", err) ); } } }