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. CentOS6.6修改主机名和网络信息

    1.修改主机名称 [root@centos ~]# vim /etc/sysconfig/network #打开文件,修改以下内容并保存 NETWORKING=yes #使用网络HOSTNAME=ce ...

  2. 在WIN7系统下用Quartus ii 11.1 NIOS II 11.1 有时候会出现Nios II 的Run as hardware 中报错:Downloading ELF Process failed

    nios工程在编译通过后RUN的过程中出现Error Running Nios II Project: ‘Downloading ELF Process failed’问题原因: 1.nios2 cp ...

  3. Java的优先级

    序列号 符号 名称 结合性(与操作数) 目数 说明 1 . 点 从左到右 双目 ( ) 圆括号 从左到右 [ ] 方括号 从左到右 2 + 正号 从右到左 单目 - 负号 从右到左 单目 ++ 自增 ...

  4. ZigZag-LeetCode

    题目: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows l ...

  5. l连接远程桌面

    参考:http://www.windows7en.com/Win7/17168.html 重要命令:mstsc

  6. PHP内置Web Server探究(一)启动Cli_Server

    自PHP5.4之后 PHP内置了一个Web 服务器(cli_server),类似于Python的内置server一样,方便我们开发阶段的调试 主要使用场景: 1,没有搭建nginx或apache等第三 ...

  7. 扩展vbox硬盘大小

    1.使用VboxManage list hdds查看所有安装的虚拟机信息   2.找到你要扩展硬盘容量虚拟机的UUID,使用modifyhd命令扩展硬盘大小 VBoxManage modifyhd U ...

  8. 网页中flash背景透明

    <embed src="文件路径" width="长度" height="宽度" quality="high" t ...

  9. [HDU] 1394 Minimum Inversion Number [线段树求逆序数]

    Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  10. 类XX是公共的,应在名为XX.java的文件中声明public class XX

    找了一个程序粘贴到txt文档中,随便起个名为abc,然后改后缀为.java,接下来在dos中运行时出现以上错误 打开abc.java看了看,声明public class了,但是名字是粘贴过来的类名Wo ...