Home  >  Q&A  >  body text

angular.js - angularjs 路由如何禁止缓存

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

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

高洛峰高洛峰2684 days ago773

reply all(3)I'll reply

  • 習慣沉默

    習慣沉默2017-05-15 16:52:30

    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

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-15 16:52:30

    . . . . . . . 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.

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-15 16:52:30

    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'
    }).

    reply
    0
  • Cancelreply