search

Home  >  Q&A  >  body text

angular.js - How to disable caching in angularjs routing

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.

高洛峰高洛峰2783 days ago861

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