Giter Club home page Giter Club logo

cachebust's People

Contributors

davinkevin avatar furzeface avatar seminull avatar stn1978 avatar williamukoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cachebust's Issues

Maintainer wanted.

I deprecated this a while back, but if it's of any use to anyone feel free to maintain it!

Feature request: add constant as an option

Right now there are only two options for the busting type, MD5 or timestamp.

In my case it would be useful if cachebust had a constant type, as in my build system I have a buildNumber variable available.
For example, today using https://github.com/furzeface/gulp-cache-bust I have

gulp.src('./dist/*/*.html')
    .pipe(cachebust({
        type: 'timestamp'
    }))
    .pipe(gulp.dest('./dist'));

What I would like is

gulp.src('./dist/*/*.html')
    .pipe(cachebust({
        type: 'constant',
        value: BUILD_NUMER
    }))
    .pipe(gulp.dest('./dist'));

Thanks

feat(selector): custom elements and attributes

The need

In Angular we use ng-href on link tags to load custom stylesheet. So we need cache busting to work on ng-href attribute.

The solution

Quick and dirty:

The discussion

As there may be need for support for other tags (img...) and other custom attributes what would be the preferred way to customize the behavior? Give in some kind of map of elements and attributes?

For ex:
options: { targets: { link: ['href', 'ng-href'], script: ['src', 'ng-src'] } }

Open to all ideas. Once we agree on a solution, I'll implement it.

cachebust.js

I was reading over the cachebust.js. It looks like it's getting an MD5 checksum on the fileContents of the given html file, and not whatever the fileContents of the given scriptSrc/styleHref. Was this intentional?

Only first resource gets replaced.

Im trying to switch from grunt to gulp... this library is very close to what I need... but apparently if you have two identical file references... only the first one will get busted in a particular page.

<script type="text/javascript">
    window.no_cache  = "client/static/js/app.js?v=thisfilegotbustedabc123";  // gets busted
</script>
<script src="client/static/js/app.js"></script>  // <!-- not busted -->

why would I do this? My project passing the md5 of the main js file and is basically using it as a Version number... (among other things). Then in my app.... I use it for additional cachebusting.. like certain ajax requests:

  // ajax httpInterceptor .. 
  // ... some code to get md5 hash etc...
  request.url = request.url + symbol + 'no_cache='+md5;

Maybe I'm doing things unlike most people... but I'm trying to keep the project simple, and implement
a basic level of cache-busting. I've looked at other setups and other options that include things like re-naming files and resources.. that just seems like overkill.

I noticed your using cheerio to loop the dom... but doing a non-global replace... so each element only replaces the first resource found.

Even if you don't want to do a global replace.. this is a bug as its finding a <script src=".."> but busting it somewhere else...

Thoughts...
Thanks.

Cachebust consider <script> tag without src attribute and failed

Hi !
I have a problem with the current version of cachebust.
I'm working with davinkevin which sent to you a message earlier : #1

Actually the problem is : if a script tag is inside our base file and this tag don't contain src attribute : cachebust failed unfortunately ;(
--> at line 50 "scripts[j].attribs.src.split("?")[0];" because src is undefined

I prepared a push request for you ;)
Let me know if you can published this fix as soon as possible ?!

relative paths don't resolve correctly in sub directories

When using relative paths in html documents in sub directories, it doesn't resolve correctly. Change the path to an absolute path and it works again. Error looks like this where doc root is www/ from gulpfile position:

$ gulp
[14:32:12] Using gulpfile ~/.../gulpfile.js
[14:32:12] Starting 'cachebust'...
fs.js:641
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/.../www/assets/js/main.js'

The correct path here would've been /.../www/cv/assets/js/main.js as it was referenced from an html doc in the www/cv/ dir with <script type="text/javascript" src="assets/js/main.js"></script>. Browsers resolve that correctly.

gulpfile looks like this:

gulp.task('cachebust', function(){
  return gulp.src('./www/**/*.html')
    .pipe(cachebust({
      type: 'MD5'
    }))
    .pipe(gulp.dest('./www'));
});

html imports not getting busted

Html imports are not getting busted.

Example import:
<link rel="import" href="elements.html" async>

Please change line 57 of /lib/cachebust.js to:
var protocolRegEx = /^(http(s)?)|\/\//, elements = $('script[src], link[rel=stylesheet][href]', link[rel=import][href]');

It should work.

Please update the gulp plugin also.

Thank you!

Doesnt work for html with innerHTML attribute

I am building a dynamic iframe with innerHTML (which has al the links and scripts as strings)
I guess in your code you try to load the elements jQuery style (cheerio)
Any chance for a quick fix to support strings as well?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.