Forum Replies Created

Viewing 15 replies - 76 through 90 (of 157 total)
  • Thread Starter phloo

    (@phloo)

    a) it appears that wp cli is working (the directory name changes after you purge it)

    yes, it does generate a new file but not the same when clicking “FVM purge” from the toolbar

    b) The hash, 498bb607109d20c2a937936f4be405b507657e2a is the same (this means, the contents inside the css files may be different, but the css file names are exactly the same).

    Yes, as is should be, from the perspective of the plugin. But here is the problem: it gets the wrong list of files. The generated HTML shows its a redesigned page. But the enqueued scripts/styles seen by FVM are wrong. Without FVM it works correctly.

    c) If it’s wpengine… disable OP Cache.

    Will try..

    Yes, the plugin issues a cache purge request to wpengine… but beware. WP Engine, limits the amount of times you can purge files. It only allows one purge every 5 minutes, so anything between it, will simply be ignored (without feedback).

    I know. But it doesnt matter if I only use it once or multiple times. WP CLI stopped working to flush the cache correctly.

    That means, it’s either cached on OP Cache or the code is incorrectly enqueued.
    Knowing wpengine, it’s likely the first one. Disable it and test.

    What I dont understand is that, if the page is OP cached, why is the html output showing the correct code (with redesign elements) but the enqueued scripts are the wrong ones?

    Thread Starter phloo

    (@phloo)

    Definately some problem with cli & wpengine
    Here is the current test.

    First: it reverted back to the old code again. Still no idea why this happens. The HTML code shows its a redesigned page, only the generated css files are wrong

    Before purging:
    https://www.xxxxxxxxxxxxx.com/wp-content/uploads/cache/fvm/1595313857/out/header-498bb607109d20c2a937936f4be405b507657e2a.min.css

    After wp cli command (still old and wrong css)
    Success: FVM and other caches were purged
    https://www.xxxxxxxxxxxxx.com/wp-content/uploads/cache/fvm/1595330316/out/header-498bb607109d20c2a937936f4be405b507657e2a.min.css

    After FVM purge from WordPress toolbar (new styles, correct view)
    https://www.xxxxxxxxxxxxx.com/wp-content/uploads/cache/fvm/1595330456/out/header-498bb607109d20c2a937936f4be405b507657e2a.min.css

    Thread Starter phloo

    (@phloo)

    First up, thanks for the explanation and help, really appreciated.

    basic setup function
    The add_action is in the theme’s default function.php and contains only enqueuing of scripts and styles, depending on pages, custom post types and plugin usage (forms).

    names of css files
    example old: fonts.css
    example new: fonts2020.css
    So they are different (also can be seen in the fvm logs)

    object cache
    The site is hosted at WPengine, so yes, there is an active caching system behind it. But flushing the cache via FVM/wp cli should also trigger the flushing of the object cache at WPE. It’s weird that the correctly written css files are overwritten after some time, hence some trigger is pushing the old css file paths instead of the new ones.

    enqueing
    In the theme functions.php I call the hook action:
    add_action('wp', 'theme_basics_setup');

    This function is loading another php file with only enqueue entries:

    $assets_path = get_template_directory_uri()."/".basename(dirname(__FILE__));
    $newcss = (get_field('redesign2020')) ? "2020" : "";
    
    /* base styles */
    wp_register_style('wp-fonts', $assets_path.'/css/fonts.css','','', 'screen' );
    wp_register_style('wp-styles', $assets_path.'/css/app.css','','', 'screen' );
    wp_register_style('responsive-styles', $assets_path.'/css/responsive'.$newcss.'.css','','', 'screen' );
    /* layout */
    wp_register_style('wp-layout-hero', $assets_path.'/css/layout/hero'.$newcss.'.css', '', '', 'screen');
    wp_register_style('wp-layout-header', $assets_path.'/css/layout/header'.$newcss.'.css', '', '', 'screen');
    wp_register_style('wp-layout-content', $assets_path.'/css/layout/content'.$newcss.'.css', '', '', 'screen');
    wp_register_style('wp-layout-footer', $assets_path.'/css/layout/footer'.$newcss.'.css', '', '', 'screen');
    
    wp_enqueue_style('wp-fonts');
    wp_enqueue_style('wp-styles');
    wp_enqueue_style('wp-layout-hero');
    wp_enqueue_style('wp-layout-header');
    wp_enqueue_style('wp-layout-content');
    wp_enqueue_style('wp-layout-footer');

    The get_field function is from the “Advanced Custom Fields” plugin. I would have guessed it may not be available when FVM checks what to merge but then again it merges the files correctly when I flush the cache manually.

    I will try to figure out why it’s still not working.

    Thread Starter phloo

    (@phloo)

    Okay, I think I found the cause for the CSS mixup.

    When I purge the FVM Cache and visit a page without the new redesign files, the cache will be generated with those files and used globally. Without checking if a single page is loading another style set.

    If I purge the FVM Cache and the first visit is a redesigned page, the files are generated as desired.

    Looks like the plugin is not able to check for single pages, right? :/

    Thread Starter phloo

    (@phloo)

    The hook is the following:
    add_action('wp_enqueue_scripts', 'theme_basics_setup');

    Inside the function I check for the custom field and change the path of the css file. Example:

    $new_css = (get_field('redesign2020')) ? "2020" : "";
    
    /* base styles */
    wp_register_style('wp-fonts', $assets_path.'/css'.$new_css.'/fonts.css','','', 'screen' );
    wp_enqueue_style('wp-fonts');

    I can change the hook to “wp” or something different.

    • This reply was modified 5 years, 10 months ago by phloo.
    Thread Starter phloo

    (@phloo)

    I change the path on the wp_enqueue_style routine.

    Thanks for the hint with the log.
    I can see it uses the “old” css files to generate the merged css files.
    As far as I can tell it’s when the page is saved and has no custom field activated (still old layout), the global css files will be with those styles.

    Is this the desired behaviour by FVM?
    Any way to get the correct styles for each page?

    Thread Starter phloo

    (@phloo)

    Ah, I checked the filenames only. My bad!

    The problem is: we are doing a re-design and upgrade single pages (there are hundreds to update manually because of new modules, etc.)

    So we added a custom field (e.g. “redesign2020”) and activate it to load the new css files (different names). When we edit it (no fvm cache activated) everything works as expected. But as soon as the page is cached. It shows the old css instead of the new files. Only after purging again the correct css shows up. And after a couple of hours (or whatever changes the behaviour) the old CSS styles are shown and we have to manually flush again.

    Thread Starter phloo

    (@phloo)

    There must be a problem with the generation of the CSS files.
    The minified filenames are exactly the same but the CSS is different (after purging FVM cache)

    old (wrong) css
    https://XXXX/wp-content/uploads/cache/fvm/1595232293/out/header-d2aa1bc8d7804d09d333f41979ea647cec4e1114.min.css

    new (correct) css after purging
    https://XXXX/wp-content/uploads/cache/fvm/1595238495/out/header-d2aa1bc8d7804d09d333f41979ea647cec4e1114.min.css

    Thread Starter phloo

    (@phloo)

    Yes, the css files have different names. I add a custom field to the post and if this is activated, I load the other css styles.

    So, the HTML is fine, shows the correct css classes but the other css styles are loaded. After I log in and click the FVM Purge link manually, everything is correct.

    “Are your generated FVM file names changing after purging caches via wp-cli?
    You need to check that, not logged in. That’s the point as logged in users don’t see fvm cached files.”

    I need to debug this. Will monitor when its happening again and check the generated css file names.

    Thread Starter phloo

    (@phloo)

    Thanks for the response and ideas.

    More info about the situation to clear things up.

    The HTML is correct, no caching issues here. I load two different versions of CSS for the same url, depending on a setting in the WP backend. Not sure if the cli command doesn‘t update the files or load the css for the older version of the page. After I flush it when logged into the WP site, the correct css is loading.

    Is there a hook to update FVM files when a page is saved? I guess it has to do a hard reset to show the correct version of the styles.

    Thread Starter phloo

    (@phloo)

    hi Nastia,

    I am still in contact with one of your developers and debugging the issue.
    Thanks for getting back!

    Thread Starter phloo

    (@phloo)

    Thanks Predrag, I mailed you the export.

    Thread Starter phloo

    (@phloo)

    Good. I am working on this – they forwarded it to their devs
    I am sure they will add the check, it’s not a big deal.

    Thanks for investigating. Glad we could find the issue.

    Thread Starter phloo

    (@phloo)

    Yeah, I saw they do not check if the given parameters are correct.
    I will forward your reply. It’s not an important bug but nice to polish all “errors”.

    Thanks

    Thread Starter phloo

    (@phloo)

    Update: talked to the guys at WPE and here is the newest info. We ran the commands with debugging on the live site and got the “error” message, which I guess, results in the curl timeout.

    Debug (hooks): On hook "before_run_command": WP_CLI\Bootstrap\RegisterDeferredCommands->add_deferred_commands() (0.688s)
    Debug (bootstrap): Running command: fvm purge (0.688s)
    something went wrong while purging WP Engine CDN: Es wurde keine gültige URL übermittelt.
    PHP Notice:  Undefined offset: 0 in /XXXXXXX/wp-content/mu-plugins/wpengine-common/plugin.php on line 2131
    Notice: Undefined offset: 0 in /XXXXXXX/wp-content/mu-plugins/wpengine-common/plugin.php on line 2131
    Success: FVM and other caches were purged.

    Here is the code part from the plugin

    View post on imgur.com

    Maybe this helps to show whats happening.

Viewing 15 replies - 76 through 90 (of 157 total)