GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Can I purge old and outdated cache files? · Issue #13291 · webpack/webpack

Can I purge old and outdated cache files? #13291

New issue
Copy link
New issue
Copy link
Closed
#21528
Closed
Can I purge old and outdated cache files?#13291
#21528
Copy link
Labels
status: staleNo author response after a needs: request; close candidatewebpack-5Concerns the webpack 5 line

Description

@otakustay
otakustay
opened on May 2, 2021
Issue body actions

Feature request

On out CI system we upload webpack's cache to a storage after each build and download them on the next build to speed up build.

After about 6 months, we find there is a 800MB cache directory with more than 100 .pack files in this cache, causing slower and slower download time.

What is the expected behavior?

We'd like to see an API to purge outdated cache content from these files, we can then run purge monthly, a slow purge process is acceptable since this runs only once per month.

What is motivation or use case for adding/changing the behavior?

Try to limit cache size in long term.

How should this be implemented in your opinion?

Maybe we should have a {purge: true} in cache configuration

Are you willing to work on this yourself?

Not able to do that

Reacted by Felipe Torres (fforres), Liri "Really" Sokol, Zen, Phil Phillips, ambar, Mehdi Slamnia, Joy Gao, akira-kuriyama and austinw-fineart

Activity

Next
  1. otakustay commented on May 2, 2021

    @otakustay
    otakustay
    on May 2, 2021
    Author
    More actions

    There is a maxAge configuration but it fails to work, maybe this is because on each download of cache the ctime and mtime is updated to current timestamp.

    This is an example of current large cache:

    -rw-rw-r-- 1 ferry ferry 119170275 Apr 29 16:37 0.pack
    -rw-rw-r-- 1 ferry ferry   3718917 Jan 25 17:17 100.pack
    -rw-rw-r-- 1 ferry ferry   2661947 Jan 22 15:16 101.pack
    -rw-rw-r-- 1 ferry ferry   2661947 Jan 22 15:16 102.pack
    -rw-rw-r-- 1 ferry ferry   2663375 Jan 22 16:13 103.pack
    -rw-rw-r-- 1 ferry ferry   1640456 Jan 25 16:39 104.pack
    -rw-rw-r-- 1 ferry ferry  27665503 Jan 25 17:18 105.pack
    -rw-rw-r-- 1 ferry ferry   2661890 Jan 25 17:17 106.pack
    -rw-rw-r-- 1 ferry ferry  35071612 Jan 25 17:18 107.pack
    -rw-rw-r-- 1 ferry ferry   1047161 Jan 25 17:18 108.pack
    -rw-rw-r-- 1 ferry ferry   3993968 Apr 29 16:54 10.pack
    -rw-rw-r-- 1 ferry ferry   3934125 Apr 29 16:54 11.pack
    -rw-rw-r-- 1 ferry ferry  56293783 Apr 29 16:54 12.pack
    -rw-rw-r-- 1 ferry ferry      5551 Apr 11 15:30 13.pack
    -rw-rw-r-- 1 ferry ferry   3153297 Apr 14 13:14 14.pack
    -rw-rw-r-- 1 ferry ferry   7043344 Apr 11 15:30 15.pack
    -rw-rw-r-- 1 ferry ferry   3900942 Apr 14 13:14 16.pack
    -rw-rw-r-- 1 ferry ferry   3149566 Apr 11 23:56 17.pack
    -rw-rw-r-- 1 ferry ferry   7088026 Apr 14 13:14 18.pack
    -rw-rw-r-- 1 ferry ferry   3153297 Apr 14 14:03 19.pack
    -rw-rw-r-- 1 ferry ferry   1700987 Apr 29 16:54 1.pack
    -rw-rw-r-- 1 ferry ferry   2776089 Apr 14 14:04 20.pack
    -rw-rw-r-- 1 ferry ferry   2774623 Apr 14 13:14 21.pack
    -rw-rw-r-- 1 ferry ferry   3923167 Apr 14 14:03 22.pack
    -rw-rw-r-- 1 ferry ferry   3912774 Apr 14 13:14 23.pack
    -rw-rw-r-- 1 ferry ferry     46629 Apr 14 19:27 24.pack
    -rw-rw-r-- 1 ferry ferry   3903555 Apr 14 14:03 25.pack
    -rw-rw-r-- 1 ferry ferry   3923088 Apr 14 19:27 26.pack
    -rw-rw-r-- 1 ferry ferry   3913944 Apr 14 14:04 27.pack
    -rw-rw-r-- 1 ferry ferry     21186 Apr 14 19:27 28.pack
    -rw-rw-r-- 1 ferry ferry   3913865 Apr 14 19:27 29.pack
    -rw-rw-r-- 1 ferry ferry  11796650 Apr 29 16:37 2.pack
    -rw-rw-r-- 1 ferry ferry   3923090 Apr 15 10:23 30.pack
    -rw-rw-r-- 1 ferry ferry   3913867 Apr 14 19:27 31.pack
    -rw-rw-r-- 1 ferry ferry  19843125 Apr 15 10:23 32.pack
    -rw-rw-r-- 1 ferry ferry    804267 Apr 15 10:23 33.pack
    -rw-rw-r-- 1 ferry ferry  77633883 Apr 15 10:23 34.pack
    -rw-rw-r-- 1 ferry ferry   8339925 Apr 15 10:23 35.pack
    -rw-rw-r-- 1 ferry ferry    915722 Mar 24 16:18 36.pack
    -rw-rw-r-- 1 ferry ferry  54512178 Mar 24 16:18 37.pack
    -rw-rw-r-- 1 ferry ferry     20272 Mar  1 17:28 38.pack
    -rw-rw-r-- 1 ferry ferry   7207882 Feb 25 14:53 39.pack
    -rw-rw-r-- 1 ferry ferry  15567825 Apr 29 16:37 3.pack
    -rw-rw-r-- 1 ferry ferry   6910049 Feb 25 14:56 40.pack
    -rw-rw-r-- 1 ferry ferry   3749063 Feb 25 14:56 41.pack
    -rw-rw-r-- 1 ferry ferry   3123047 Feb 26 13:31 42.pack
    -rw-rw-r-- 1 ferry ferry   3057770 Feb 26 13:31 43.pack
    -rw-rw-r-- 1 ferry ferry   3066902 Mar  1 14:34 44.pack
    -rw-rw-r-- 1 ferry ferry   4625389 Feb 26 13:31 45.pack
    -rw-rw-r-- 1 ferry ferry   6848282 Feb 27 20:10 46.pack
    -rw-rw-r-- 1 ferry ferry   7004505 Feb 27 20:22 47.pack
    -rw-rw-r-- 1 ferry ferry   2738477 Mar  1 13:06 48.pack
    -rw-rw-r-- 1 ferry ferry   2736264 Feb 27 20:23 49.pack
    -rw-rw-r-- 1 ferry ferry   4015881 Apr 29 16:37 4.pack
    -rw-rw-r-- 1 ferry ferry   6995269 Feb 27 20:23 50.pack
    -rw-rw-r-- 1 ferry ferry   5317760 Mar  1 13:06 51.pack
    -rw-rw-r-- 1 ferry ferry      9569 Mar  1 14:34 52.pack
    -rw-rw-r-- 1 ferry ferry   5319970 Mar  1 13:20 53.pack
    -rw-rw-r-- 1 ferry ferry  13243263 Feb 28 14:35 54.pack
    -rw-rw-r-- 1 ferry ferry   3806612 Mar  1 14:08 55.pack
    -rw-rw-r-- 1 ferry ferry   2739458 Mar  1 14:08 56.pack
    -rw-rw-r-- 1 ferry ferry   3792612 Mar  1 17:26 57.pack
    -rw-rw-r-- 1 ferry ferry   4932428 Mar  1 15:25 58.pack
    -rw-rw-r-- 1 ferry ferry   4348053 Mar  1 17:26 59.pack
    -rw-rw-r-- 1 ferry ferry  18028905 Apr 29 16:37 5.pack
    -rw-rw-r-- 1 ferry ferry   7116517 Mar  1 14:34 60.pack
    -rw-rw-r-- 1 ferry ferry      9327 Mar  1 15:26 61.pack
    -rw-rw-r-- 1 ferry ferry   3810131 Mar  1 17:26 62.pack
    -rw-rw-r-- 1 ferry ferry     10025 Mar  1 14:35 63.pack
    -rw-rw-r-- 1 ferry ferry   2739458 Mar  1 17:26 64.pack
    -rw-rw-r-- 1 ferry ferry  26548396 Mar  1 17:26 65.pack
    -rw-rw-r-- 1 ferry ferry   2742727 Mar  1 17:26 66.pack
    -rw-rw-r-- 1 ferry ferry   7174612 Mar  1 17:26 67.pack
    -rw-rw-r-- 1 ferry ferry    777805 Mar  1 17:26 68.pack
    -rw-rw-r-- 1 ferry ferry   3871561 Mar  1 17:28 69.pack
    -rw-rw-r-- 1 ferry ferry  10872590 Apr 29 16:54 6.pack
    -rw-rw-r-- 1 ferry ferry   2736264 Mar  1 17:29 70.pack
    -rw-rw-r-- 1 ferry ferry   6900815 Mar  1 17:28 71.pack
    -rw-rw-r-- 1 ferry ferry  51530310 Mar  1 17:29 72.pack
    -rw-rw-r-- 1 ferry ferry   1111500 Mar  1 17:29 73.pack
    -rw-rw-r-- 1 ferry ferry   4993954 Jan 20 17:41 74.pack
    -rw-rw-r-- 1 ferry ferry   3700456 Jan 20 17:43 75.pack
    -rw-rw-r-- 1 ferry ferry   3711839 Jan 22 10:29 76.pack
    -rw-rw-r-- 1 ferry ferry   3701559 Jan 20 18:46 77.pack
    -rw-rw-r-- 1 ferry ferry   3692586 Jan 20 17:54 78.pack
    -rw-rw-r-- 1 ferry ferry     33649 Jan 22 16:14 79.pack
    -rw-rw-r-- 1 ferry ferry  21270722 Apr 29 16:53 7.pack
    -rw-rw-r-- 1 ferry ferry   3702384 Jan 20 18:54 80.pack
    -rw-rw-r-- 1 ferry ferry   3693411 Jan 20 18:46 81.pack
    -rw-rw-r-- 1 ferry ferry  23651993 Jan 22 10:29 82.pack
    -rw-rw-r-- 1 ferry ferry   3701285 Jan 20 18:59 83.pack
    -rw-rw-r-- 1 ferry ferry   3692308 Jan 20 18:54 84.pack
    -rw-rw-r-- 1 ferry ferry   3713051 Jan 25 16:39 85.pack
    -rw-rw-r-- 1 ferry ferry   3701285 Jan 20 19:01 86.pack
    -rw-rw-r-- 1 ferry ferry   3692308 Jan 20 18:59 87.pack
    -rw-rw-r-- 1 ferry ferry   3703147 Jan 21 17:09 88.pack
    -rw-rw-r-- 1 ferry ferry   3694171 Jan 20 19:01 89.pack
    -rw-rw-r-- 1 ferry ferry   4026682 Apr 29 16:53 8.pack
    -rw-rw-r-- 1 ferry ferry   3704062 Jan 22 16:14 90.pack
    -rw-rw-r-- 1 ferry ferry   3703008 Jan 21 17:14 91.pack
    -rw-rw-r-- 1 ferry ferry   3694033 Jan 21 17:09 92.pack
    -rw-rw-r-- 1 ferry ferry   3702849 Jan 22 10:29 93.pack
    -rw-rw-r-- 1 ferry ferry   3703290 Jan 22 10:24 94.pack
    -rw-rw-r-- 1 ferry ferry   3694315 Jan 21 17:15 95.pack
    -rw-rw-r-- 1 ferry ferry   3712423 Jan 22 15:07 96.pack
    -rw-rw-r-- 1 ferry ferry   3703433 Jan 22 10:29 97.pack
    -rw-rw-r-- 1 ferry ferry     81079 Jan 25 17:18 98.pack
    -rw-rw-r-- 1 ferry ferry      5484 Jan 25 16:39 99.pack
    -rw-rw-r-- 1 ferry ferry     87419 Apr 29 16:37 9.pack
    -rw-rw-r-- 1 ferry ferry   4606528 Apr 29 16:54 index.pack
    -rw-rw-r-- 1 ferry ferry   4606102 Apr 29 16:53 index.pack.old
    

    The same project with a single build locally:

    -rw-r--r--  1 otakustay  staff   125M May  2 16:38 0.pack
    -rw-r--r--  1 otakustay  staff    77M May  2 16:38 1.pack
    -rw-r--r--  1 otakustay  staff    15M May  2 16:38 2.pack
    -rw-r--r--  1 otakustay  staff   3.7M May  2 16:38 index.pack
    -rw-r--r--  1 otakustay  staff   3.7M May  2 16:38 index.pack.old
    
  2. sokra commented on May 2, 2021

    @sokra
    sokra
    on May 2, 2021
    Member
    More actions

    Yep I know about this problem. MaxAge does cleanup old cache entries, but no longer used files are not removed from disk...

  3. otakustay commented on May 2, 2021

    @otakustay
    otakustay
    on May 2, 2021
    Author
    More actions

    Perhaps we can include cache outdated information in output stats

  4. sokra commented on May 2, 2021

    @sokra
    sokra
    on May 2, 2021
    Member
    More actions

    Perhaps we can include cache outdated information in output stats

    You can set infrastructureLogging: { level: "verbose" } to get a few more lines of logging about the caching.

    On short term we want to fix the cache issue by removing all unused files from the cache directory after writing the cache. That sounds easy but actually it a bit tricky since, due to lazy deserialization of the cache, we don't know all files that are currently in use. We might change the cache format a little bit to know these details.

    Reacted by Henry Hang, Felipe Torres (fforres) and qlin
  5. webpack-bot
    added
    webpack-5Concerns the webpack 5 line
    question
    on May 4, 2021
  6. fforres commented on Jul 27, 2021

    @fforres
    fforres
    on Jul 27, 2021
    More actions

    I'm on the same boat, using filesystem caches to speedup our CI builds.
    I'm on a big org and project, so after a week and a bit more, our cache got to ~27gb 😅.

    @sokra looking @ the code, I see the file serialization middleware lib/serialization/FileMiddleware is used only fore createFileSerializer inside serialization.js (And also print-cache-file.js, which i'm seeing is a debugging/tool #10400 (comment)).

    What would be a good approach for a short term fix?

    I have a naive approach to fix this locally passing down a purgeStaleCache prop, reading the files inside the cache dir, comparing against allWrittenFiles and deleting what's not used. Pretty much adding all that in between these lines.

    https://github.com/webpack/webpack/blob/main/lib/serialization/FileMiddleware.js#L472-L474

    Maybe the idea is for serialization middlewares to be more generic in the long run, so creating/deleting files specifically for cache might be too specific or not ideal? However, in the short time WDYT of this PR? #13875

    Either way, any guidance is welcome.

  7. fforres commented on Aug 11, 2021

    @fforres
    fforres
    on Aug 11, 2021
    More actions

    ping @sokra (cc @otakustay) I have an implementation here #13875

    I'd appreciate any revie/comments

  8. fforres commented on Aug 19, 2021

    @fforres
    fforres
    on Aug 19, 2021
    More actions

    Friendly Ping/reminder! :D

  9. vankop commented on Sep 15, 2021

    @vankop
    vankop
    on Sep 15, 2021
    Contributor
    More actions

    @sokra is it still an issue?

  10. sokra commented on Sep 16, 2021

    @sokra
    sokra
    on Sep 16, 2021
    Member
    More actions

    Yes

  11. alexander-akait
    added
    enhancement
    and removed
    question
    on Dec 21, 2021
  12. hiyuki commented on Dec 21, 2021

    @hiyuki
    hiyuki
    on Dec 21, 2021
    More actions

    In filesystem cache, the unused cache items are now splited to a new cache content file partially, perhaps we need a config to remove it, just like maxGenerations:1 works in memory cache.

    Reacted by Alexander Akait
  13. vankop commented on Dec 21, 2021

    @vankop
    vankop
    on Dec 21, 2021
    Contributor
    More actions

    there is an opened PR #14661

    Reacted by Alexander Akait and Felipe Torres (fforres)
  14. 28 remaining items

  15. webpack-bot
    removed
    status: staleNo author response after a needs: request; close candidate
    on Jul 10, 2024
  16. alexander-akait
    moved this from Shipped to Priority - Medium in webpack 5/6on Jul 10, 2024
  17. BlackCat1397 commented on Jul 31, 2024

    @BlackCat1397
    BlackCat1397
    on Jul 31, 2024
    More actions

    This issue Is still present on Webpack 5.91.0.
    Cache size easily grows to 5 Gb during work.

    Reacted by Tom Williams and sumit
  18. webpack-bot
    added
    status: staleNo author response after a needs: request; close candidate
    on Oct 31, 2024
  19. webpack-bot
    closed this as completedon Nov 15, 2024
  20. alexander-akait
    reopened this on Nov 15, 2024
  21. webpack-bot
    removed
    status: staleNo author response after a needs: request; close candidate
    on Nov 15, 2024
  22. webpack-bot
    added
    status: staleNo author response after a needs: request; close candidate
    on Feb 15, 2025
  23. webpack-bot
    closed this as completedon Mar 2, 2025
  24. alexander-akait
    reopened this on Mar 3, 2025
  25. nakzyu commented on Jul 14, 2025

    @nakzyu
    nakzyu
    on Jul 14, 2025
    More actions

    Is there any progress or planned update on this issue?

  26. sumitjhajharia commented on Jan 30, 2026

    @sumitjhajharia
    sumitjhajharia
    on Jan 30, 2026
    More actions

    Do we plan any fixes on this issue ? Currently there is no way to identify stale cache packs. If we can get list of packs which are stale so it can be cleared from storage.

  27. alexander-akait commented on Jan 30, 2026

    @alexander-akait
    alexander-akait
    on Jan 30, 2026
    Member
    More actions

    Yes, we will plan to fix this

  28. bysiber commented on Mar 4, 2026

    @bysiber
    bysiber
    on Mar 4, 2026
    More actions

    This is a common issue with long-running projects, webpack's filesystem cache directory grows unbounded over time. The 800MB with 100+ .pack files situation is very typical.

    For local development machines (especially macOS), ClearDisk is a free menu bar tool that monitors developer cache paths in real-time. While it doesn't prune webpack's internal cache format, it helps you track when your project's cache directories (including node_modules, build caches, etc.) start consuming too much space.

    For the specific CI use case mentioned here, a built-in cache.maxAge or cache.purge config would solve this cleanly, being able to automatically discard pack files older than N days.

  29. alexander-akait
    closed this as completedin #21528on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: staleNo author response after a needs: request; close candidatewebpack-5Concerns the webpack 5 line

    Type

    No type

    Fields

    Priority

    None yet

    Projects

      • webpack 5/6
        Closed
        Status
        Priority - Medium
        Show more project fields

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.