• Resolved justyumyum

    (@justyumyum)


    Hi there,

    I’m serving my plugins and the remaining content from two different subdomains.

    static1.mydomain.com for plugins only, static2.mydomain.com for all other folders of wp-content.

    Means:

    1. Autoptimize as a plugin is stored on static1, the cache folder for Autoptimize on static2.

    2. JS and CSS files of plugins from plugins are served from static1, JS and CSS files from the theme etc. are served from static2.

    I’ve checked the options “optimze js” and “optimize css”, “save combined css/script files as static files”, base cdn url is empty.

    The cache folder has the correct full path “/home/www/static2.mydomain.com/cache/autoptimize/ and the folder is also writeable.

    For some reason, Autoptimize doesn’t build any cache files.

    Could your please help?

    Thanks and best regards
    Carsten

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

    (@futtta)

    For some reason, Autoptimize doesn’t build any cache files.

    given the extensive explanation of your particular setup, I guess you have gut feeling why it doesn’t ??

    anyway; the best starting point here would be to install the development version of AO, which has significant improvements in the function that is used to map URL’s to filesystem paths. you can download that version from GitHub here, overwrite wp-content/plugins/autoptimize with the contents of autoptimize-master/ in the zip-file.

    frank

    Thread Starter justyumyum

    (@justyumyum)

    Hi Frank

    Thanks for your quick reply and thanks for the master version.

    Actually I don’t have a clue, I’m just a well experienced ticket writer ??

    Now it works for the files coming from static2 (new “wp-content” location), but the css and js files from static1 (plugins) aren’t bundled yet.

    Probably because I use the constant WP_PLUGIN_URL for a different plugin path and so it isn’t part of the WP_CONTENT_URL anymore?

    Thanks and Cheers
    Carsten

    Plugin Author Frank Goossens

    (@futtta)

    Probably because I use the constant WP_PLUGIN_URL for a different plugin path and so it isn’t part of the WP_CONTENT_URL anymore?

    probably. try this code snippet to tell AO it should try to aggregate files from static1.mydomain.com as well;

    add_filter('autoptimize_filter_cssjs_multidomain','yumyam_add_domain');
    function yumyum_add_domain($domains) {
        $domains[] = "static1.mydomain.com";
        return $domains;
    }
    Thread Starter justyumyum

    (@justyumyum)

    nope, unfortunetaly the filter doesn’t catch static1. wether css nor js files get combined (I’ve seen the typo in the function name within add_filter, so that’s not the reason.)

    • This reply was modified 7 years, 10 months ago by justyumyum.
    Plugin Author Frank Goossens

    (@futtta)

    OK … we could probably work around this with a bit of additional directory traversal logic inside another snippet (remove the previous one);

    add_filter('autoptimize_filter_cssjs_alter_url','yumyum_domain_magic');
    function yumyum_domain_magic($url) {
        if (strpos($url,"//static1.domain.com/") !== false) {
    	  $url = str_replace( "//static1.domain.com/", "//static2.domain.com/../static1.domain.com/", $url );
    	}
        return $url;
    }

    a bit of a hack, but it just might work ??

    Thread Starter justyumyum

    (@justyumyum)

    Yeah, now it works perfectly!!! Thank you SO much, Frank.

    Have a look yourself at https://www.justyumyum.de/ – page load time of below 500 ms and performance grade of 94 with pingdom tools

    Cheers
    Carsten

    • This reply was modified 7 years, 10 months ago by justyumyum.
    Plugin Author Frank Goossens

    (@futtta)

    nice numbers, great job Carsten!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Autoptimize on subdomains’ is closed to new replies.