chrisdwheatley/netlify-plugin-image-optim

Add caching

ehmicky opened this issue · 0 comments

Image processing can be quite slow.

It would be great if the minified images could be cached, so minification does not happen on the next build if the image has not changed.

For example:

  • {publishDir}/image.png is found
  • It is minified to {publishDir}/image-{hash}.png, where hash is the file's content hash
  • cache.save('{publishDir}/image-{hash}.png') is called (see cache utility documentation here)
  • on the next run, cache.restore('{publishDir}/image-{hash}.png') is called. If it returns true, that file does not need to be minified again
  • {publishDir}/image-{hash}.png is finally moved to {publishDir}/image.png

What do you think?