P3X Angular HTTP Cache Interceptor v2020.10.132
Example
This is configured to cache, so, it caches everything, unless you use the CachingHeaders.NoCache header in your request. Should you wish to use a per-module cache, in the interceptor configuration, you would use the CachingStore.PerModule store configuration.

import { P3XHttpCacheInterceptorModule,
CachingHeaders, CachingStore }
from 'p3x-angular-http-cache-interceptor';

@NgModule({
  declarations: [],
  imports: [
    P3XHttpCacheInterceptorModule.forRoot({
      behavior: CachingHeaders.Cache,
      store: CachingStore.Global,
    }),
    CommonModule
  ]
})
export class NonCacheModule { }



Itt will try to load some random data, based on the default interceptor behavior without using headers.




Itt will try to load some random data with cached data. You can see in the browser inspector network tab, that there will be only one request. Here, we use the CachingHeaders.Cache header.




It will try to load some random data without cache. You can see in the browser inspector network tab, that every click will talk to a server and retrieve the new data. Here, we use the CachingHeaders.NoCache header.