{"id":13807117,"url":"https://github.com/patrikx3/angular-http-cache-interceptor","last_synced_at":"2025-09-20T10:02:50.538Z","repository":{"id":57317517,"uuid":"260025222","full_name":"patrikx3/angular-http-cache-interceptor","owner":"patrikx3","description":"🔥 Angular HTTP cache interceptor","archived":false,"fork":false,"pushed_at":"2025-02-01T18:12:15.000Z","size":1607,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-09T12:52:32.295Z","etag":null,"topics":["all","angular","cache","client","everything","headers","http","http-client","interact","intercept","request"],"latest_commit_sha":null,"homepage":"https://www.corifeus.com/angular-http-cache-interceptor","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrikx3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-29T19:39:27.000Z","updated_at":"2025-06-19T05:50:38.000Z","dependencies_parsed_at":"2024-04-25T07:30:32.751Z","dependency_job_id":"39ac6e4c-2b72-4dde-9e0b-dee4fb42e9f2","html_url":"https://github.com/patrikx3/angular-http-cache-interceptor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/patrikx3/angular-http-cache-interceptor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fangular-http-cache-interceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fangular-http-cache-interceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fangular-http-cache-interceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fangular-http-cache-interceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrikx3","download_url":"https://codeload.github.com/patrikx3/angular-http-cache-interceptor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fangular-http-cache-interceptor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269769878,"owners_count":24473210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["all","angular","cache","client","everything","headers","http","http-client","interact","intercept","request"],"created_at":"2024-08-04T01:01:21.130Z","updated_at":"2025-09-20T10:02:45.450Z","avatar_url":"https://github.com/patrikx3.png","language":"TypeScript","readme":"[//]: #@corifeus-header\n\n  [![NPM](https://img.shields.io/npm/v/p3x-angular-http-cache-interceptor.svg)](https://www.npmjs.com/package/p3x-angular-http-cache-interceptor)  [![Donate for PatrikX3 / P3X](https://img.shields.io/badge/Donate-PatrikX3-003087.svg)](https://paypal.me/patrikx3) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Corifeus @ Facebook](https://img.shields.io/badge/Facebook-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)  [![Uptime ratio (90 days)](https://network.corifeus.com/public/api/uptime-shield/31ad7a5c194347c33e5445dbaf8.svg)](https://network.corifeus.com/status/31ad7a5c194347c33e5445dbaf8)\n\n\n\n\n\n# 🔥 Cache every request in Angular, not only the GET, but all methods of this interceptor, and allows you to interact with the interceptor via specific headers and modify the request, and these specific headers will be not included in the final request v2025.4.124\n\n\n  \n🌌 **Bugs are evident™ - MATRIX️**  \n🚧 **This project is under active development!**  \n📢 **We welcome your feedback and contributions.**  \n    \n\n\n\n### NodeJS LTS is supported\n\n### 🛠️ Built on NodeJs version\n\n```txt\nv22.13.1\n```\n\n\n\n\n# 📦 Built on Angular\n\n```text\n19.1.4\n```\n\n\n\n# 📝 Description\n\n                        \n[//]: #@corifeus-header:end\n\n\u003c!--\nBased on [@d4h/angular-http-cache](https://www.npmjs.com/package/@d4h/angular-http-cache), but it works without any configuration and a different implementation, so they are not the same at all, but the idea is the same.\n--\u003e\n\nUsually, when you want to cache all requests, you do not cache all requests, but only the `GET` method. But, for some frontend applications, it is required to cache everything, otherwise the subsequent requests, without cache, would slow down the application flow.  So, this micro-service caches all method/path/query variables/parameters/request body.\n  \nThe way, we can find out what we are caching it is not simple. Usually, you would cache by a key of the `httpRequest.urlWithParams` and only the `GET` HTTP method.\n\nTo create this cache key, this package is using the `object-hash` package, with the following algorithm:\n```ts\nimport hash from 'object-hash'\n\nconst hashOptions = {\n  algorithm: 'md5',\n  encoding: 'hex'\n}\n\nhttpToKey(httpRequest: HttpRequest\u003cany\u003e) {\n    const key = httpRequest.method + '@' + httpRequest.urlWithParams + '@' + hash(httpRequest.params, hashOptions) + '@' + hash(httpRequest.body, hashOptions)\n    return key\n}\n```\n\nThere is room in the future, to restrict to specific methods and add more configurations and functions. If there is a need for this micro-service, it could be enhanced, but for now, it is caching everything, with the exception, when you include the `CachingHeaders.NoCache` header into your request, then this request will always hit the server. \n\n# Example web page that uses this package\nhttps://angular-http-cache-interceptor.corifeus.com\n\n# How to use it\n\n```bash\nnpm i p3x-angular-http-cache-interceptor object-hash\n```\n\n## Include the caching interceptor into your Angular module\n```ts\nimport { NgModule } from '@angular/core';\n\nimport { P3XHttpCacheInterceptorModule  } from 'p3x-angular-http-cache-interceptor';\n\n@NgModule({\n  declarations: [\n  ],\n  imports: [\n    P3XHttpCacheInterceptorModule,\n  ],\n  providers: [\n  ],\n  bootstrap: []\n})\nexport class SomeModule { }\n```\n\n### Options\n```ts\nimport { P3XHttpCacheInterceptorModule, CachingHeaders, CachingStore  } from 'p3x-angular-http-cache-interceptor';\n\nP3XHttpCacheInterceptorModule.forRoot({\n    // default request is no cache\n    behavior: CachingHeaders.NoCache,\n    \n    // if a request has CachingHeaders.Cache header it will cache globally\n    store: CachingStore.Global,\n})\n\nP3XHttpCacheInterceptorModule.forRoot({\n    // default request is cache\n    behavior: CachingHeaders.Cache,\n\n    // in this config, it will cache not globally, but per module\n    store: CachingStore.PerModule,\n})\n```\n\n## Example invocation in a component\n\nWith and without cache:\n```ts\nimport { Component } from '@angular/core';\n\nimport { HttpClient } from \"@angular/common/http\";\nimport {MatSnackBar} from \"@angular/material/snack-bar\";\n\nimport { CachingHeaders } from 'p3x-angular-http-cache-interceptor'\n\n@Component({\n  selector: 'p3x-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.scss']\n})\nexport class AppComponent {\n\n  constructor(\n    private http: HttpClient,\n    private snack: MatSnackBar,\n  ) {\n  }\n\n  async loadCached() {\n    try {\n      const response : any = await this.http.get('https://server.patrikx3.com/api/core/util/random/32').toPromise()\n      this.snack.open(`Will be always the same: ${response.random}`, 'OK')\n    } catch(e) {\n      this.snack.open(`Sorry, error happened, check the console for the error`, 'OK')\n      console.error(e)\n    }\n  }\n\n  async loadNonCached() {\n    try {\n      const response : any = await this.http.get('https://server.patrikx3.com/api/core/util/random/32', {\n        headers: {\n          [CachingHeaders.NoCache]: '1'\n        }\n      }).toPromise()\n      this.snack.open(`Truly random data: ${response.random}`, 'OK')\n    } catch(e) {\n      this.snack.open(`Sorry, error happened, check the console for the error`, 'OK')\n      console.error(e)\n    }\n  }\n\n}\n```\n\n\n\n[//]: #@corifeus-footer\n\n---\n\n## 🚀 Quick and Affordable Web Development Services\n\nIf you want to quickly and affordably develop your next digital project, visit [corifeus.eu](https://corifeus.eu) for expert solutions tailored to your needs.\n\n---\n\n## 🌐 Powerful Online Networking Tool  \n\nDiscover the powerful and free online networking tool at [network.corifeus.com](https://network.corifeus.com).  \n\n**🆓 Free**  \nDesigned for professionals and enthusiasts, this tool provides essential features for network analysis, troubleshooting, and management.  \nAdditionally, it offers tools for:  \n- 📡 Monitoring TCP, HTTP, and Ping to ensure optimal network performance and reliability.  \n- 📊 Status page management to track uptime, performance, and incidents in real time with customizable dashboards.  \n\nAll these features are completely free to use.  \n\n---\n\n## ❤️ Support Our Open-Source Project  \nIf you appreciate our work, consider ⭐ starring this repository or 💰 making a donation to support server maintenance and ongoing development. Your support means the world to us—thank you!  \n\n---\n\n### 🌍 About My Domains  \nAll my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](https://corifeus.eu), and [corifeus.com](https://corifeus.com), are developed in my spare time. While you may encounter minor errors, the sites are generally stable and fully functional.  \n\n---\n\n### 📈 Versioning Policy  \n**Version Structure:** We follow a **Major.Minor.Patch** versioning scheme:  \n- **Major:** 📅 Corresponds to the current year.  \n- **Minor:** 🌓 Set as 4 for releases from January to June, and 10 for July to December.  \n- **Patch:** 🔧 Incremental, updated with each build.  \n\n**🚨 Important Changes:** Any breaking changes are prominently noted in the readme to keep you informed.\n\n---\n\n\n[**P3X-ANGULAR-HTTP-CACHE-INTERCEPTOR**](https://corifeus.com/angular-http-cache-interceptor) Build v2025.4.124\n\n [![NPM](https://img.shields.io/npm/v/p3x-angular-http-cache-interceptor.svg)](https://www.npmjs.com/package/p3x-angular-http-cache-interceptor)  [![Donate for PatrikX3 / P3X](https://img.shields.io/badge/Donate-PatrikX3-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=QZVM4V6HVZJW6)  [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)\n\n\n\n\n\n[//]: #@corifeus-footer:end\n","funding_links":["https://paypal.me/patrikx3","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=QZVM4V6HVZJW6"],"categories":["Architecture and Advanced Topics"],"sub_categories":["HTTP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrikx3%2Fangular-http-cache-interceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrikx3%2Fangular-http-cache-interceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrikx3%2Fangular-http-cache-interceptor/lists"}