Skip to content

Add a way to provide a custom cacheBuster #306

@zhouzi

Description

@zhouzi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions