Skip to content

Instantly share code, notes, and snippets.

@tieppt
Created January 6, 2019 11:31
Show Gist options
  • Save tieppt/7ce8730120996c1d300f594d819a6516 to your computer and use it in GitHub Desktop.
Save tieppt/7ce8730120996c1d300f594d819a6516 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import {
HttpHandler,
HttpProgressEvent,
HttpInterceptor,
HttpSentEvent,
HttpHeaderResponse,
HttpUserEvent,
HttpRequest,
HttpResponse
} from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable()
export class NoCacheHttpInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
const nextReq = req.clone({
setHeaders: {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': 'Sat, 01 Jan 2000 00:00:00 GMT',
'If-Modified-Since': '0'
}
});
return next.handle(nextReq);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment