在前端我使用AngularJS"$ resource"作为GET请求,在后端我使用SpringMVC公开我的方法Restful方式.
现在我想只缓存一些我的GET请求.我注意到有一些方法可以像使用$ cacheFactory一样.或类似的东西:
return {
Things: $resource('url/to/:thing', {}, {
list : {
method : 'GET',
cache : true
}
};
Run Code Online (Sandbox Code Playgroud)
请注意,这也可能是一个带有一些缓存参数的简单ajax调用,而不是必须使用angularJS.
所以不是在客户端上使用这种方法,我想知道它可以在服务器上完成,只需通过Java在Response头中设置缓存,有些事情如下:
response.setHeader("Cache-Control: max-age=2592000");
Run Code Online (Sandbox Code Playgroud)
这两种方法有什么区别?应该采用哪种方法?
PS这个问题不是服务器端缓存与客户端缓存问题,我只需在服务器中设置HTTPResponse头即可.