Support » Plugin: Cloudflare » Automatic Cache Management and Large Custom Menus

  • Eric

    (@ekyle)


    It seems that the Automatic Cache Management option can cause some problems when large custom navigation menus are being edited due to the way those items are updated. We were getting timeouts when editing a menu with a large number of items and having ACM activated, but upon deactivation, were not experiencing the timeouts. Perhaps you can do something to handle the ACM flush differently when custom menus are updated. For now we are just leaving ACM deactivated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author jwineman

    (@jwineman)

    Hi @ekyle,

    We hook on these actions for ACM:
    https://github.com/cloudflare/Cloudflare-WordPress/blob/master/cloudflare.loader.php#L55-L58

    Do you know which hook is triggering the time out?
    Are there any errors in the PHP error log?
    Are you able to provide us with sample arguments being passed to those hooks so we can try to reproduce and debug?

    Thanks,
    John

    Eric

    (@ekyle)

    Most likely it is on the edit_post action since each menu item is a post and updating the menu item causes each to be updated as well. Here are the relevant functions associated with a menu update.

    wp_nav_menu_update_menu_items()
    wp_update_nav_menu_item()
    update_post_meta()
    wp_update_post()
    wp_insert_post()

    The last, wp_insert_post, executes the edit_post action. So it would seem that’s where the inefficiency may be. Granted, I have not delved into the CloudFlare plugin code so I could be mistaken as to the cause.

    https://github.com/cloudflare/Cloudflare-WordPress/blob/master/cloudflare.loader.php#L84

    There are no errors, just the timeout.

    The menu in question has 600 items. Without ACM active, it saves in under 12 seconds, but with ACM, it exceeds the time allowed for script execution on the server.

    As an alternative to disabling ACM all the time, we can just disable it during menu edits. I hope this information helps.

    Plugin Author thellimist

    (@furkan811)

    Hi @ekyle,

    In …/plugins/Cloudflare folder there is a file named config.js. Could you edit that file and make debug: true

    https://github.com/cloudflare/Cloudflare-WordPress/blob/master/config.js#L2

    then try to activate edit_post hook by editing a post?

    In your PHP error logs you should see something like “List of URLs purged are…”

    https://github.com/cloudflare/Cloudflare-WordPress/blob/master/src/WordPress/Hooks.php#L162

    If you can please tell us how many items are in there.

    Thanks

    Eric

    (@ekyle)

    There are only 24 items in the purged URLs array and appears that the purge cache succeeds based on the message “DEBUG:purgeCacheByRevelantURLs succeeded”.

    However, the menu never finishes saving and a 502 error is generated. The 502 error is caused by the host stopping the script from exceeding a threshold of time, so technically the problem is not caused by the CloudFlare plugin, but the environment it is in.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Automatic Cache Management and Large Custom Menus’ is closed to new replies.