ocombe / ocLazyLoad

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

Add a way to provide a custom cacheBuster #306

Open zhouzi opened 8 years ago

zhouzi commented 8 years ago

For now setting cache to false causes the files to be reloaded every time and there's no way to manage any kind of revisions. A better solution would be to define a version that's updated when the files change (e.g on a new release). That been said, the way you want to manage versioning may differ so the choices should be left to the developers.

It could be solved by providing a custom cacheBuster that receives and returns an url, the default one would be:

function defaultCacheBuster (url) {
  var stamp = Date.now();
  // code to add "stamp" as a query parameter
  // e.g: /statics/js/app.js?v=93012321
  return url;
}

For the record, here's the current implementation: https://github.com/ocombe/ocLazyLoad/blob/master/src/ocLazyLoad.loaders.common.js#L23

I'll probably submit a PR as it became a requirement for some of the apps I'm working on.

michael-yuen commented 8 years ago

+1

ballinascreen commented 8 years ago

+1

phobos-labs commented 8 years ago

+1

zhouzi commented 8 years ago

@michael-yuen @ballinascreen @phobos-labs I finally had some time to implement this and submitted two PRs. The first one adds a way to provide a custom cacheBuster function #336 and the second one adds a way to configure every modules' config defaults #335

They are probably not going to be merged any time soon so you can get those two features by installing the forked version: npm install wizbii/ocLazyLoad#merge. "merge" is a branch with the two branches merged.