WordPress.org

Ready to get started?Download WordPress

Forums

Autoptimize
[resolved] garbage collection (5 posts)

  1. blau
    Member
    Posted 4 months 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?

    https://wordpress.org/plugins/autoptimize/

  2. futtta
    Member
    Plugin Author

    Posted 4 months 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,
    frank

  3. blau
    Member
    Posted 4 months 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?

    https://www.example.com/wp-admin/options-general.php?page=autoptimize&settings-updated=true

  4. futtta
    Member
    Plugin Author

    Posted 4 months ago #

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

    autoptimizeCache::clearall();

    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
    Member
    Posted 4 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic