Compress icon indicating copy to clipboard operation
Compress copied to clipboard

Cache

Open RichardLindhout opened this issue 3 years ago • 15 comments

It would be nice if there would a cache folder where the already compressed images are in so they won't need a new compression. It takes long to do the images on my website currently so deployment is slower.

RichardLindhout avatar Nov 04 '22 15:11 RichardLindhout

@RichardLindhout I have thought about that! 😁 But that would require some harder thinking.

NikolaRHristov avatar Nov 04 '22 15:11 NikolaRHristov

But expect it in 1.2.0

NikolaRHristov avatar Nov 04 '22 15:11 NikolaRHristov

I noticed the slow build times on https://github.com/nikolaxhristov/astro.build.compress.critters, as well and also some errors ough

NikolaRHristov avatar Nov 04 '22 15:11 NikolaRHristov

@NikolaRHristov does this work now, would be really cool!

RichardLindhout avatar Jul 20 '23 10:07 RichardLindhout

Hey @RichardLindhout, still not I'm afraid 😅 That's why astro-compress is still version 1.1.x 🤣

NikolaRHristov avatar Jul 20 '23 10:07 NikolaRHristov

I have some time over the weekend so I'll give it a crack.

NikolaRHristov avatar Jul 20 '23 10:07 NikolaRHristov

Wow that would be so great!!

RichardLindhout avatar Jul 20 '23 17:07 RichardLindhout

Hey @NikolaRHristov Thanks again for opening that PR against FusionAuth!

I know you are trying to pull back from this project, but did you have thoughts on how this would work? I might hack on this and make a PR if you haven't gotten very far.

lyleschemmerling avatar Aug 15 '23 15:08 lyleschemmerling

Yeah, no problem! I've been thinking about using the internal git cache of a repository and simply outputting a folder with already processed files. Then just calling that folder to see if something's cached or not. The simplest of things.

sequenceDiagram
    participant User
    participant AstroCompress
    participant Cache
    participant FilesPipe
    participant Git

    User->>AstroCompress: Input Files
    loop Check Cache
        AstroCompress->>Cache: Check if cached
        Cache-->>AstroCompress: Cache status
    end
    alt Cache Found
        AstroCompress->>Cache: Retrieve from Cache
        Cache-->>AstroCompress: Cached Files
    else Cache Not Found
        AstroCompress->>FilesPipe: Process Files
        FilesPipe-->>AstroCompress: Processed Files
        AstroCompress->>Cache: Store in Cache
        Cache-->>AstroCompress: Cache Stored
        AstroCompress->>Git: Commit Processed Files
        Git-->>AstroCompress: Commit ID
    end
    Git->>User: Commit ID
    alt Processed Files Changed
        AstroCompress->>Cache: Replace Cached Files
        Cache-->>AstroCompress: Replacement Done
    end
    AstroCompress->>User: Output Files

That way you can stage that folder in git and have those files persisted, so every time AstroCompress is executed on the CI or somewhere it can have something to work with.

NikolaRHristov avatar Aug 15 '23 15:08 NikolaRHristov

This would ideally be implemented in FilesPipe - https://github.com/NikolaRHristov/FilesPipe

NikolaRHristov avatar Aug 15 '23 15:08 NikolaRHristov

This is very well still in its ideation stage and PRs are welcome.

NikolaRHristov avatar Aug 15 '23 17:08 NikolaRHristov

Thank you, I love your package. Really looking forward to the caching feature.

azat-io avatar Feb 09 '24 21:02 azat-io

Thank you, I love your package. Really looking forward to the caching feature.

🙏🏻 Yeah, same, this is a hard feature.

NikolaRHristov avatar Feb 10 '24 01:02 NikolaRHristov