[AngualrJS] Using Angular-Cache for caching http request
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的更多相关文章
- Data caching per request in Owin application
Data caching per request in Owin application 解答1 Finally I found OwinRequestScopeContext. Very simpl ...
- 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 ...
- was unable to refresh its cache! status = Cannot execute request on any known server
出现这种错误是因为: Eureka服务注册中心也会将自己作为客户端来尝试注册它自己,所以我们需要禁用它的客户端注册行为. 在 yml中设置 eureka.client.register-with-eu ...
- [转] 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 ...
- [转] 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 ...
- http header cache-control (request和response区别)
摘要:(1)网络服务会根据 request的header中的 cache-control策略设置response的cache-control策略 1 response cache-control 和 ...
- 请求方式:request和 get、post、put
angular 的 http 多了 Request, Headers, Response ,这些都是游览器的"新特性" Fetch API. Fetch API 和以前的 xmlh ...
- Page.Cache
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.page.cache?view=netframework-4.8 Gets the ...
- 025-缓存Cache
如果每次进入页面的时候都查询数据库生成页面内容的话,如果访问量非常大,则网站性能会非常差.而如果只有第一次访问的时候才查询数据库生成页面内容,以后都直接输出内容,则能提高系统性能.这样无论有多少人访问 ...
随机推荐
- React 入门最好的实例-TodoList
React 的核心思想是:封装组件,各个组件维护自己的状态和 UI,当状态变更,自动重新渲染整个组件. 最近前端界闹的沸沸扬扬的技术当属react了,加上项目需要等等原因,自己也决定花些时间来好好认识 ...
- Linux下的压缩和解压
1. gzip, bzip2 能否直接压缩目录呢?不可以 2. 请快速写出,使用gzip和bzip2压缩和解压一个文件的命令.压缩:gzip 1.txt bzip2 1.txt解压:gzip -d 1 ...
- ASP.net获取当前页面的文件名,参数,域名等方法
ASP.net后台获取当前页面的文件名 System.IO.Path.GetFileName(Request.Path).ToString(); 获取当前页面文件名,参数,域名等方法 假设当前页完整地 ...
- Access restriction: The type * is not accessible due to restrict,报错问题
解决方案1: Eclipse 默认把这些受访问限制的API设成了ERROR. Windows -> Preferences -> Java -> Compiler -> Er ...
- respondsToSelector的使用
- (BOOL)respondsToSelector:(SEL)aSelector; 用来判断是否有以某个名字命名的方法 +(BOOL) instancesRespondToSelector: sel ...
- 访问MySQL数据库时,报“找不到请求的 .net Framework 数据提供程序。可能没有安装。”的解决方案
最近开发了一个系统,在测试环境上进行部署(win7环境)并测试,没有发现问题:但是把系统部署到win Server2008R2上之后,部分页面就报“找不到请求的 .net Framework 数据提供 ...
- 学习CAS实现SSO单点登录
学习CAS实现SSO单点登录 网上找了几篇比较详细的教程,在这记录一下: 原理: CAS实现SSO单点登录原理 教程: 1.CAS实现单点登录(SSO)经典完整教程 2.SSO之CAS单点登录实例演示 ...
- visual studio 未将对象引用设置到对象的实例
我今天在win10上安装了Visual Studio 2015,结果新建项目后在模板中选择一项后就会弹出一个对话框: 查了许多种方法后,下面这个方法解决了我这个问题: 著作权归作者所有.商业转载请联系 ...
- 使用ToolRunner运行Hadoop程序基本原理分析
为了简化命令行方式运行作业,Hadoop自带了一些辅助类.GenericOptionsParser是一个类,用来解释常用的Hadoop命令行选项,并根据需要,为Configuration对象设置相应的 ...
- POJ1636 动态规划+并查集
POJ1636 问题重述: 两个监狱中各有m个囚犯,欲对这两个监狱中的囚犯进行等数量的交换.已知某些囚犯不能关押在同一个监狱,求解可以交换人数的最大值k (k < m/2). 分析: 假设监狱1 ...