jgable / gulp-cache

A cache proxy task for Gulp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache invalidation

retrocausal opened this issue · comments

Hi I have been trying to find a way to invalidate a cache key on file deletion
the issue is,

Let us assume there are three css files I am minifying and then concatenating
As of now, I am doing it this way

Gulp task - styleTask:

gulp.src(css/**/*.css)
.pipe(cache(cleanCss()))
.pipe(concat('app.css')
.pipe(gulp.dest(dist))

Then I watch the css folder with
gulp.watch('css/**/*',['styleTask'])
Everything works perfect.

However, on deletion of a file, I need to delete the corresponding cache entries too.

Is that a possibility via configuration?

else,

I can manually delete them, If I have the cache keys handy.

The plugin creates multiple cache entries per file whenever it is modified,

would it be possible to return the cache key by exposing API methods?

I can then just clear those entries instead of clearing the whole cache

Also, One quick question.

Assume the task is :

gulp.src('css/*/.css')
.pipe(cache(cleanCss())
.pipe(concat('app.css'))
.pipe(gulp.dest('build/css'))

what would cache pass downstream to concat?

What I could make out is,

  1. it caches minified files via cleanCss
  2. if there is a cache hit, file is not minimized. - what is passed down to concat in such case? will the cache serve the file?

If so, shouldn't the file be served from /tmp/gulp-cache/default/hash?

right now, if I log the path of the file, I am getting the original path and not the cached path

Sorry, been really swamped lately and haven't had time to answer questions. Hoping to get some time by the end of the week.

Answer for #60 (comment):

Remove all the CSS files in the dist directory before running styleTask with rimraf. Then, whenever you delete one of the watched files, it won't remain in the dist directory.

Answer for #60 (comment)

if there is a cache hit, file is not minimized. - what is passed down to concat in such case? will the cache serve the file?

Minified files.

From next time,

  1. Please write a clearer issue title instead of too abstract one, such as "Cache invalidation".
  2. Please create one issue per problem.