• Resolved gmcinnes

    (@gmcinnes)


    Hi: I expected autoptimize should only regenerate its js and css when you click “Save changes and empty cache” (esp. if “Save agregatted script/css….” is turned on).

    But in my cache directories, I’m seeing the files being regenerated at strange, unexpected times. More worryingly the files are often different sizes, although the underlying scripts / css hasn’t changed.

    Sometimes the files are obviously broken, being only a few hundred bytes long, and my users see unstyled content.

    Here’s a gist with the content of the cache directories: https://gist.github.com/gmcinnes/ade5ccbd120f101a71bf0bb6d1f8f5c6

    Any idea what could be causing that? Have I misconfigured something, or misunderstood how it’s supposed to work?

    https://ww.wp.xz.cn/plugins/autoptimize/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frank Goossens

    (@futtta)

    Evening gmcinnes;
    Autoptimize generates new cached files every time it detects even the slightest difference with what has been cached already (even 1 character difference will do). Differences between pages can occur because some plugins will only inject css and/ or js only when they are active on that particular case. Also the CSS/ JS loaded for logged in users (you) is (slightly) different from what anonymous visitors see. If you feel there are too many files there, you could always try to go through your site (as anonymous user) and compare the files between pages/ posts/ archives and try to exclude the non-generic JS or CSS from optimization (or even use the whitelist-functionality that is available via the API).

    Now if some users report unstyled pages, that is a whole other issue, obviously. Have you encountered these yourself as well? Is the autoptimized CSS-file missing (404) or corrupt? Do you have links you could share where this would be the case?

    frank

    Thread Starter gmcinnes

    (@gmcinnes)

    First, Frank, you deserve huge kudos and thanks for being so amazing at support. It’s very rare for even *paid* plugins to have the level of support you provide for free.

    I haven’t seen these issues myself. They’re transient even for people who are experiencing them. I don’t have a consistent reproduction case yet.

    Given what you said, am I right in thinking that there would be an autoptimize css file for each *page* that has slightly different css, and that those files wouldn’t change unless the underlying css for one of those pages does?

    Plugin Author Frank Goossens

    (@futtta)

    am I right in thinking that there would be an autoptimize css file for each *page* that has slightly different css, and that those files wouldn’t change unless the underlying css for one of those pages does?

    that is correct. this can even become a real problem if, when aggregating inline JS (or CSS, but that’s less likely), there is ‘random’ code added (e.g. nonce’s). that can cause a new autoptimized file being created over and over, which can slow down page performance and “explodes” the cache in which case one should either exclude such “cache-busting” code from aggregation or simply disable aggregation of inline JS (or CSS). more info in the FAQ, off course 🙂

    frank

    Thread Starter gmcinnes

    (@gmcinnes)

    Ok Frank. That’s good to know. I won’t bother aggregating the inline assets. It’s not worth the extra problems.

    I have another question: I seem to have a problem getting jQuery into the aggregation. Most everything else depends on it, so I need to make sure it gets into the aggregated file first. Is there any way to control the order of the files in the aggregation?

    Plugin Author Frank Goossens

    (@futtta)

    Is there any way to control the order of the files in the aggregation?

    well, autoptimize aggregates in the exact order things are found, so -on condition you aggregate everything, inline JS included- this should be OK.

    if you’re not aggregating inline JS (and/ or excluding some non-inline JS), then you might have to “force JS into head” (so your autoptimized JS with jquery is loaded early) or alternatively simply exclude jquery.js from optimization.

    frank

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Randomly regenerating css and js’ is closed to new replies.