unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
1.54k stars 61 forks source link

feat: add cache support #47

Closed ascorbic closed 11 months ago

ascorbic commented 2 years ago

Adds support for a local cache of source images. I can add tests and docs if you're happy with the approach. It uses unstorage to store metadata on the cached files (etag, lastModified) and murmurhash to create filenames based on the URL.

Let me know if this seems like a good apporach and I'll finish off the PR!

Fixes #46

codecov-commenter commented 2 years ago

Codecov Report

Merging #47 (e63c14f) into main (eafe4ca) will decrease coverage by 2.14%. The diff coverage is 22.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #47      +/-   ##
==========================================
- Coverage   45.60%   43.46%   -2.15%     
==========================================
  Files          10       10              
  Lines         296      329      +33     
  Branches       54       66      +12     
==========================================
+ Hits          135      143       +8     
- Misses        159      184      +25     
  Partials        2        2              
Impacted Files Coverage Δ
src/sources/http.ts 28.57% <18.18%> (-7.80%) :arrow_down:
src/ipx.ts 77.41% <66.66%> (-0.55%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update eafe4ca...e63c14f. Read the comment docs.

pi0 commented 2 years ago

Thanks for PR @ascorbic. It is a nice start. BTW to points:

pi0 commented 11 months ago

Hi dear @ascorbic thanks again for initiative work on this ❤️ I plan to rework this with new storage implementation for IPX 0.2.x. Closing PR for triage.