ocLazyLoad
ocLazyLoad copied to clipboard
Add a way to provide a custom cacheBuster
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.
+1
+1
+1
@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.