Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to clear cache? #9

Closed
nullcitizen opened this issue Feb 19, 2014 · 6 comments · Fixed by #12
Closed

How to clear cache? #9

nullcitizen opened this issue Feb 19, 2014 · 6 comments · Fixed by #12

Comments

@nullcitizen
Copy link

So I randomly had an issue when using the cache on images, where the gulp-images plugin would spit out the same image for all images, and after some debugging, this seemed to be related to gulp-cache. When I take caching out it works fine, but if I put the cache in, I get all the same image.

Anyways, I am guessing that clearing out this cache would solve it. Any suggestions on how to remove the cached items so image minification can go back to normal?

@jgable
Copy link
Owner

jgable commented Feb 19, 2014

I think you've got two things here, one is the bug for how they were all the same image, and one is a feature request for how to force clear the cache.

For the bug, can you paste your gulp-images proxy code for me to take a look at?

For the feature, I think that's a good feature to have, gonna create a new issue for it. How do you feel about something like this:

gulp.task('clearCache', function() {
  // Still pass the files to clear cache for
  gulp.src('./lib/*.js')
    .pipe(cache.clear());

  // Or, just call this for everything
  cache.clearAll();
});

@nullcitizen
Copy link
Author

Absolutely! And thank you for a really fast response!

I've removed irrelevant bits, but you can see this in full at:
https://github.com/joecochran/chassis/blob/master/gulpfile.js

var cache = require('gulp-cache');

gulp.task('images', function() {
    return gulp.src('app/assets/img/**/*')
        .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
        .pipe(livereload(server))
        .pipe(gulp.dest('public/img'))
        .pipe(notify({ message: 'images task complete' }));
});

@jgable
Copy link
Owner

jgable commented Feb 19, 2014

Thanks, I'll clone it down and try to take a look this afternoon.

@jgable
Copy link
Owner

jgable commented Feb 19, 2014

Ran into something weird with the imagemin task. Looks like it is emitting data out of order, which I can fix. I just would like to have a unit test for it and I can't seem to make any of my stuff go out of order.

jgable added a commit that referenced this issue Feb 19, 2014
Reported in #9

- Add check for same file before resolving the promise
@jgable
Copy link
Owner

jgable commented Feb 19, 2014

Now published as 0.1.2 on NPM. Should work correctly with imagemin now.

Thanks for the feedback and let me know if you find any other weird things.

@brendanfalkowski
Copy link

Figured I'd mention an issue I was having with gulp-cache and reference #16 also.

I had two subdomains setup running the same repo with same NPM packages (all updated). One would generate optimized images, and one would not. My "images" task ran but the images were never output on that site. The only difference as far as I know is the failing site was initialized today. After simplifying the test case and setting up another site, I narrowed it down to gulp-cache. Removing it solved the problem

Found this article: http://stackoverflow.com/questions/21532903/strange-images-issue-with-gulp-js

Then rewrote using gulp-newer which works as expected locally and on the server. I'm honestly not sure why gulp-cache worked on the first site (always worked locally). Anyway if someone gets stuck that might help.

These were my versions:

Node 0.10.28
NPM 1.4.9
gulp ^3.7.0
gulp-cache ^0.2.2
gulp-imagemin ^1.0.1

And my task:

gulp.task('images', function () {
    return gulp.src('img-src/**/*')
        .pipe(cache(imagemin({
            interlaced: true,
            optimizationLevel: 3,
            progressive: true,
            svgoPlugins: [{
                removeViewBox: false
            }]
        })))
        .pipe(gulp.dest('img'))
        .on('error', handleError);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants