ocLazyLoad icon indicating copy to clipboard operation
ocLazyLoad copied to clipboard

Add a way to provide a custom cacheBuster

Open zhouzi opened this issue 8 years ago • 4 comments

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.

zhouzi avatar May 11 '16 19:05 zhouzi

+1

michael-yuen avatar May 16 '16 20:05 michael-yuen

+1

ballinascreen avatar Jun 09 '16 10:06 ballinascreen

+1

phobos-labs avatar Jun 09 '16 10:06 phobos-labs

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

zhouzi avatar Aug 03 '16 13:08 zhouzi