[resolved] garbage collection (5 posts)

  1. blau
    Posted 1 year ago #

    It seems that on my installs autoptimize couldo do with some garbage collection - I end up with an 80GB /wp-content/cache/autoptimize containing 2.5 million files.

    This would be ok except that during upgrades the server chokes trying to get hold of the cache.

    Is there something I can do to enforce periodic cache purge?


  2. Frank Goossens
    Plugin Author

    Posted 1 year ago #

    There is no automatic purge I'm afraid Blau. In general the cache size becomes huge if you have some (js) code which is different for each page (or even every page load), in which case a new aggregated file is created. In that case the easiest solution would be to:

    1. disable JS optimization
    2. look at the HTML source of 2 very similar pages and find the javascript that is different between those 2 pages
    3. inside that different javascript find a string that is common (e.g. in "var naughty_js = <random_value>" that would be "naughty_js"
    4. go to the autoptimize settings page and make sure the advanced settings are shown
    5. add the string from (3) to "Exclude scripts from Autoptimize:" (which is a comma-seperated list).
    6. re-enable JS optimization

    hope this helps,

  3. blau
    Posted 1 year ago #

    Hi Frank, thank you for your reply.

    Would it be feasible to have a cron job clear the cache, say, weekly? What would the command be? This one?


  4. Frank Goossens
    Plugin Author

    Posted 1 year ago #

    No, you'd have to do this from PHP:


    The problem with automatic cache pruning is that it is entirely possible that a page caching layer (which could be a browser, a caching reverse proxy or a wordpress page caching plugin) could contain pages that refer to the aggregated JS/CSS-files you would delete with the purge, which would severly break the page.

    So although cache purging is on my wishlist, I don't have a good idea of how to tackle that problem yet.

  5. blau
    Posted 1 year ago #

    I see. I will keep an eye on the cache to see if it grows again. Thank you for your time.

    Edit: 1000 files in 20 minutes. Disabled js optimizing and let's see.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Autoptimize
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic