• Related to https://wordpress.org/support/topic/many-404-errors-but-only-from-googlebot/?replies=10

    The main problem when getting 404 for gone optimized files is its file name. So I suggest to never change optimized filenames, but add to output ?ver={ upper then previous } to force browsers get new version from server instead of cached in next conditions:
    1. If anyone files have changed because of new $ver that was set in functions wp_register_ / wp_enqueue_, or because of new md5 hash value of each file.
    2. Inline code/scripts, that was changed as well.

    The only two reasons to change optimized filenames will:
    1. js/css are might differ because of different pages.
    2. After purge cache. But leave appropriate notice with consequences for search engines.

    happy holidays 🙂

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

    (@futtta)

    there seems to be some misunderstanding of how AO works here @esemlabel.

    high-level;
    1. ao extracts all CSS (or JS) from the HTML captured from the output buffer
    2. all CSS (or JS) is concatenated in one string (so there’s no notion of version or page or … the code is all that matters and ideally the same hash occurs on multiple pages)
    3. a hash (md5) is created based on the string with concatenated code
    4. based on the hash the minified file is fetched from cache or the file is minified and written to cache

    so;
    * one autoptimize_<md5hash>.<ext> can be shared between different pages (if the code was identical)
    * a version-string update in the wp queue has no impact
    * the hash stays the same if the code is identical
    * if the aggregated code changens, the hash changes

    hope this clarifies,
    frank

    Thread Starter esemlabel

    (@esemlabel)

    2. There is no problem to get string that contains ‘?ver=’ from buffer on each .css or .js file, I think (strpos, substr..).
    3. There is possibility to get all scripts and styles connected to page ($wp_scripts, $wp_styles), so hash can be checked for each file to decide if we need to change ?ver= for final minified file autoptimize_<blognamescripts_numberofminifieduniqfile>.<ext>?ver=newversion.

    I clearly understand how AO works, but I’m assured that there is way to deal with 404 once for all, but maybe not the way as described. I’m planning to make some working code of such realization, and will keep you update if I can.

    Thank you!

    Plugin Author Frank Goossens

    (@futtta)

    not sure I entirely understand what you’re aiming for, but working code will help a lot 🙂

    feel free to fork on github & issue pull requests if you feel your code would benefit all!

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

The topic ‘404 topic again’ is closed to new replies.