Inicio - Documentación - POM Cache - 09 Developers - Integrate post invalidation

Integrate post invalidation

POM Cache can clear current-site HTML and progressive JSON after viewable content changes. Use the built-in purge settings for normal WordPress edits, and call the public post helpers when an external integration changes public data outside those standard events.

Automatic post invalidation

When the corresponding HTML purge setting is enabled, POM Cache attaches to post saves, deletion, trash and restore, status transitions, term assignments, and relevant taxonomy changes.

Progressive JSON registers its own set of hooks only when the JSON master and matching purge settings are enabled. HTML and JSON automation are therefore independent.

The post helpers skip:

  • invalid IDs;
  • the same last processed post in one request;
  • revisions;
  • autosaves;
  • missing post objects;
  • post types WordPress does not consider viewable.

An allowed post change clears the whole current-site store for that representation. It does not try to infer every archive, home page, feed, related-content block, or taxonomy URL that may contain the post.

Call the helpers from a custom synchronizer

function my_plugin_after_remote_post_sync( $post_id ) {
    $post = get_post( $post_id );
    if ( ! $post instanceof WP_Post ) {
        return;
    }

    if ( function_exists( 'pom_cache_delete_site_cache_for_post' ) ) {
        pom_cache_delete_site_cache_for_post(
            $post_id,
            $post,
            'my_plugin_remote_sync'
        );
    }

    if ( function_exists( 'pom_cache_json_delete_site_cache_for_post' ) ) {
        pom_cache_json_delete_site_cache_for_post(
            $post_id,
            $post,
            'my_plugin_remote_sync'
        );
    }
}

Both functions return the post ID for WordPress-hook compatibility. Do not interpret the return value as “files were deleted.”

Veto a post type

Use separate filters when an internal viewable post type cannot affect one representation:

add_filter(
    'pom_cache_clear_post_cache',
    static function ( $allow, $post ) {
        if ( 'internal_notice' === $post->post_type ) {
            return false;
        }

        return $allow;
    },
    10,
    2
);

add_filter(
    'pom_cache_json_clear_post_cache',
    static function ( $allow, $post ) {
        if ( 'internal_notice' === $post->post_type ) {
            return false;
        }

        return $allow;
    },
    10,
    2
);

Preserve previous vetoes and test all relationships. A post type that has no public singular URL can still affect a public archive, navigation, block, search result, or progressive payload.

Term assignment timing

POM Cache also handles object-term assignment because category or taxonomy membership changes archive output. If your importer bypasses WordPress's normal APIs or updates a custom table that influences templates, WordPress cannot announce that dependency automatically. Call the site helper once after the complete logical change.

Verification

For each custom invalidation:

  1. generate the affected HTML and JSON while signed out;
  2. perform the change;
  3. confirm the relevant current-site count or file is removed;
  4. request the public route and verify updated content;
  5. confirm unrelated stores stay intact when deliberately excluded;
  6. invalidate the CDN after origin verification.

For multi-item operations, do not call these full-site helpers inside every loop iteration. Use the strategy in Design bulk operations.