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
@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);
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
@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.
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
@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
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
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,
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