Check the website: https://jmdobry.github.io/angular-cache/#using-angular-cache-with-http

Install:

npm install --save angular-cache
  getServiceDetail( serviceId = "mock" ) {

    if(!this.CacheFactory.get(`${this.prefix}.${serviceId}`)){
this.$http.defaults.cache = this.CacheFactory(`${this.prefix}.${serviceId}`, {
maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
});
} return this.$http.get( `${this.CONFIG.BACKEND_API_URL}/services/${serviceId}/details`,
{
cache: this.CacheFactory.get(`${this.prefix}.${serviceId}`)
} )
.then( ( res ) => { return res.data.serviceDetail;
}, ( err ) => {
this.$log.debug( `ServiceDetails --> getServiceDetail err: Cannnot get detail data: ${JSON.stringify( err, null, 3 )}` );
throw err;
} );
}
}

[AngualrJS] Using Angular-Cache for caching http request的更多相关文章

  1. Data caching per request in Owin application

    Data caching per request in Owin application 解答1 Finally I found OwinRequestScopeContext. Very simpl ...

  2. spring cloud Bug之was unable to refresh its cache! status = Cannot execute request on any known server

    可能原因: 1.application.yml server: port: 10001spring: application: name: microservice-consumer-movieeur ...

  3. was unable to refresh its cache! status = Cannot execute request on any known server

    出现这种错误是因为: Eureka服务注册中心也会将自己作为客户端来尝试注册它自己,所以我们需要禁用它的客户端注册行为. 在 yml中设置 eureka.client.register-with-eu ...

  4. [转] KVM storage performance and cache settings on Red Hat Enterprise Linux 6.2

    Almost one year ago, I checked how different cache settings affected KVM storage subsystem performan ...

  5. [转] KVM I/O slowness on RHEL 6

    KVM I/O slowness on RHEL 6 http://www.ilsistemista.net/index.php/virtualization/11-kvm-io-slowness-o ...

  6. http header cache-control (request和response区别)

    摘要:(1)网络服务会根据 request的header中的 cache-control策略设置response的cache-control策略 1 response cache-control 和 ...

  7. 请求方式:request和 get、post、put

    angular 的 http 多了 Request, Headers, Response ,这些都是游览器的"新特性" Fetch API. Fetch API 和以前的 xmlh ...

  8. Page.Cache

    https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.page.cache?view=netframework-4.8 Gets the ...

  9. 025-缓存Cache

    如果每次进入页面的时候都查询数据库生成页面内容的话,如果访问量非常大,则网站性能会非常差.而如果只有第一次访问的时候才查询数据库生成页面内容,以后都直接输出内容,则能提高系统性能.这样无论有多少人访问 ...

随机推荐

  1. [Angular 2] Using the @Inject decorator

    TypeScript is used heavily as we build up our application, but TypeScript isn’t required. If you wan ...

  2. Leetcode_num3_Same Tree

    题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are ...

  3. IPMITOOL常用操作指令

    一.开关机,重启 1. 查看开关机状态: ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登录用户名) -P (BMC 登录用户名的密码) power statu ...

  4. js 计算某年某周日期范围

    <HTML><HEAD><script type="text/javascript"> //目前只判断了4位有效输入的年份,//日期输出格式已处 ...

  5. Nutch+Hadoop集群搭建

    转载自:http://www.open-open.com/lib/view/open1328670771405.html 1.Apache Nutch    Apache Nutch是一个用于网络搜索 ...

  6. WordPress页面函数功能代码调用大全

    WordPress模板基本文件 style.css 样式表文件index.php 主页文件single.php 日志单页文件page.php 页面文件archvie.php 分类和日期存档页文件sea ...

  7. AFNetworking 使用方法(2.0)

    AFNetworking 使用方法(2.0) 分类: IOS2014-11-12 09:17 2018人阅读 评论(0) 收藏 举报   目录(?)[+]   本文介绍的是AFNetworking-2 ...

  8. 那两年炼就的Android内功修养

    http://blog.csdn.net/luoshengyang/article/details/8923485 http://iconsparadise.com/ http://blog.csdn ...

  9. 懂说话,让冲突、尴尬时刻都bye-bye

    回忆一下自己从小到大的成长历程,你容不容易交到新朋友?在不熟悉的社交场合中,你是否也曾面临坐立难安.不知从何聊起的窘境?事实上,无论身处学校或社会,担任职务是基础或高阶,终其一生都会派上用场的能力,就 ...

  10. hdu 1596 find the safest road

    http://acm.hdu.edu.cn/showproblem.php?pid=1596 #include <cstdio> #include <cstring> #inc ...