Elementor 开发者文档

title: "Cache Changed URLs" post_status: publish comment_status: open taxonomy: category: - elementor-developers-docs post_tag: - Hosting - Src - Repos


Cache Changed URLs

Elementor hosting offers the option to add custom co-changing URLs to the page cache whenever a specific content type (post, comment, WooCommerce product etc.) is updated. This can be useful for keeping cache up-to-date for pages that depend on the updated content.

Hook Details

The dynamic portion of the hook name, $content_type, refers to the content type, e.g post, comment, woocommerce_product etc.

Hook Arguments

Argument Type Description
urls array An array of URLs.
content_id int Content ID.

Examples

Clear cache for dynamic content updates, using the following code:

/**
 * @param array
 * @param int
 * @return array
 */
function custom_clear_cache_on_woccomerce_update( $urls, $product_id ) {
    if ( ( ! is_array( $urls ) ) || empty( $urls ) ) {
        $urls = [];
    }

    $url[] = site_url('/my-path');

    return $urls;
}
add_filter( 'elementor/hosting/page_cache/woocommerce_product_changed_urls', 'custom_clear_cache_on_woccomerce_update', 10, 2 );