• Resolved hassantafreshi

    (@hassantafreshi)


    Hi everyone,
    As the developer of the?Easy Form Builder plugin, I’m seeking advice on potential conflicts with NitroPack?.

    Here’s the function I’m using for internal caching:

    public function get_efbFunction($state) {    if (isset($this->efbFunction)) return $this->efbFunction;    $efbFunctionInstance;    if (false === ($efbFunctionInstance = wp_cache_get('efbFunctionInstance', 'emsfb'))) {        if (!class_exists('Emsfb\efbFunction')) {            require_once(EMSFB_PLUGIN_DIRECTORY . 'includes/functions.php');        }        $efbFunctionInstance = new \Emsfb\efbFunction();        wp_cache_set('efbFunctionInstance', $efbFunctionInstance, 'emsfb', 3600); // 1 hour cache    }    $this->efbFunction = $efbFunctionInstance;    if ($state == 1) return $this->efbFunction;}

    I’m concerned that using?wp_cache_get?and?wp_cache_set?for internal caching might cause conflicts with NitroPack? . Has anyone encountered similar issues or know of best practices to ensure compatibility?

    Any guidance or insights would be greatly appreciated.

    Thank you for your help!

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support phristanov

    (@phristanov)

    Hey @hassantafreshi ,

    Thanks for your patience on this one.

    We do not provide object caching and it will not interfere. Also, when you are adding a form to a post or a page, the cache is being automatically flushed upon publishing the changes. However, in case he wants to clear a single page/post cache he can use:

    nitropack_purge($url = NULL, $tag = NULL, $reason = NULL)
    e.g. nitropack_purge(NULL, “single:$postID”, $reason);
    nitropack_purge(NULL, “post:$postID”, $reason);

    or invalidate it similarly by using:

    nitropack_invalidate(NULL, “post:$postID”, $reason);
    nitropack_invalidate(NULL, “single:$postID”, $reason);

    Best,
    Plamen, Head of Support at NitroPack

    Thread Starter hassantafreshi

    (@hassantafreshi)

    @phristanov Thank you for your response. My question now is whether “single” refers to the same thing as “page,” and what other values can be passed to the function below, besides “post” or “single”?

    nitropack_purge(NULL, “post:$postID”, $reason=NULL);

    Plugin Support phristanov

    (@phristanov)

    Hey @hassantafreshi ,

    Thanks for the prompt reply.

    What I can suggest is checking our documentation HERE and HERE. You should be able to find all the necessary information that you need there.

    Let me know if there is something else we can help with.

    Best,
    Plamen, Head of Support at NitroPack

    Thread Starter hassantafreshi

    (@hassantafreshi)

    @phristanov
    Thank you for your response, and apologies for the delayed reply. I checked both links and searched for the function you mentioned in the previous post, ‘nitropack_purge,’ but I couldn’t find any documentation. Could you please assist me and share a direct link to the documentation regarding this function?

    Thanks.

    Plugin Support phristanov

    (@phristanov)

    Hey @hassantafreshi ,

    Thanks for your response.

    In this case, it’s better to use?nitropack_invalidate(NULL, "post:$postID", $reason);?The $postID is the postID in?wp_posts?table, so it can be anything there, as long as it’s added in the Optimize Custom post types in NitroPack settings.

    I have checked and we need to update our documentation about these. If you want to learn more, in this case, you should check in the root folder of NitroPack, file functions.php

    Let me know if this helps.

    Best,
    Plamen, Head of Support

    Thread Starter hassantafreshi

    (@hassantafreshi)

    @phristanov
    Thank you for your response. A question has come to my mind now: If we want to clear the cache of a page using this function, do we need to make any changes to this function?

    nitropack_invalidate(NULL, "post:$postID", $reason);

    Best Regards

    Plugin Support phristanov

    (@phristanov)

    Hey @hassantafreshi ,

    If you would like to clear the cache instead of invalidating it, the nitropack_invalidate will not be really useful.

    Instead, you can clear the cache with this function:

    function
    nitropack_sdk_purge($url = NULL, $tag = NULL, $reason = NULL, $type = \NitroPack\SDK\PurgeType::COMPLETE)

    Let me know if you have any further questions.

    Best,
    Plamen, Head of Support

    Thread Starter hassantafreshi

    (@hassantafreshi)

    case 'nitropack':
    //nitropack
    $url = get_permalink($page_id);
    if(function_exists('nitropack_sdk_purge'))nitropack_sdk_purge($url);
    break;

    @phristanov Thanks for the response. We added this piece of code. In your opinion, is this the correct way to call your plugin function?

    ?Best Rergards,

    Plugin Support phristanov

    (@phristanov)

    Hey @hassantafreshi ,

    Thanks for the quick response.

    Everything seems to be looking right. You can always test it locally to confirm that the URL will be purged. You can also add a reason for the cache purge, in order to track the purge request in the Events History Tab.

    Let me know in case you need further help.

    Best,
    Plamen, Head of Support at NitroPack

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.