ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Add cacheBuster option #336

Open zhouzi opened 8 years ago

zhouzi commented 8 years ago

This PRs moves the cacheBuster function to a configurable option. That way you can manage how the urls are generated and thus the cache invalidated, e.g:

angular
  .module('app', [
    'oc.lazyLoad',
  ])
  .config([
    '$ocLazyLoadProvider',
    function ($ocLazyLoadProvider) {
      $ocLazyLoadProvider.config({
        cacheBuster: function (url) {
          // this is just an example and will not work for urls
          // that already have query parameters
          return url + '?_cache=' + window.assetsVersion;
        }
      });
    }
  ]);

Related to #306

Note: the cacheBuster is used only when the cache option is set to false, which is a per file option. If you want to set cache to false for every modules, have at look at #335

zhouzi commented 8 years ago

Historically, some loaders weren't using the cacheBuster so I am adding them one by one as I'm needing them. Let me know if I've missed one that's useful to you.

luismatesanz commented 8 years ago

When change is merge with master branch? I really need it.

zhouzi commented 8 years ago

@luismatesanz I am afraid this PR is not going to be merged any time soon. If you really need it, you can install this fork via: npm install wizbii/ocLazyLoad#merge

ronaldohoch commented 7 years ago

Up! :D

We need it.