angular.js - How to disable caching in angularjs routing
高洛峰
高洛峰 2017-05-15 16:50:30
0
3
840

As mentioned. angularjs loads different route templates, but it always uses cache and reloading the page doesn't work. Wouldn't it be possible to get the latest data from the database? How can I disable the routing mechanism from using cache?

The response header of a certain js file.
When loading the template, only js and css files are requested, and page requests are not sent.

高洛峰
高洛峰

拥有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