angular.js - angularjs 路由如何禁止缓存
高洛峰
高洛峰 2017-05-15 16:50:30
0
3
824

如题。angularjs加载不同的路由模板,但是它总是使用缓存,重新加载页面都没用。这样岂不是都取不到数据库的最新数据。如何才能禁止路由机制使用缓存?

某个js文件的响应头。
加载模板时只有请求js和css文件,不发页面请求了。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
習慣沉默

Angular’s ​​default template loading will be cached. The caching service used is $tempalteCache, and the service that sends template requests is $templateRequest. You can have two options:

1. After each $http request template is sent, you call $tempalteCache.remove(url) or removeAll to clear all template caches
2. Use $provide.decorator to rewrite the original $templateRequest and disable caching. In the source code of $templateRequest, you can see that it uses $tempalteCache as the cache by default. You can remove it

我想大声告诉你

. . . . . . . If you use Angular and then write the data into the template, what's the difference between using it and not using it?
The data should be written in the resolve of the route and bound in the template.

仅有的幸福

Add a time parameter page after your template page and it will be reloaded every time. I don’t know if that’s what you mean

when('/data', {
    templateUrl: 'partial/customer_ask.html?t=' + Math.floor(Date.now() / 1000),
    controller: 'dataController'
}).
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template