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.

Invalidate exact single URLs

Use pom_cache_delete_html_urls(array $urls): bool when an integration owns a precise set of public single URLs, including URLs captured before a post is permanently deleted.

$urls = array(get_permalink($post_id));
$cleared = pom_cache_delete_html_urls($urls);

Supply absolute URLs without query strings. The helper removes only the corresponding HTML file; it does not traverse directories, clear the home page, delete other singles or clear progressive JSON. Capture canonical URLs, language variants and known aliases before deleting the post. The caller remains responsible for deciding which representations belong to that content.

The return value is true when every supplied target is valid and its HTML file is absent after invalidation. Invalid URLs, an unavailable cache root, an empty target list or an unlink failure return false. Retry failed invalidation before reporting that a deleted page can no longer be served.

The default host allowlist contains the current site's home host. Multilingual integrations using additional domains can extend the array with pom_cache_html_purge_hosts. Add only domains belonging to the current site. Root URLs, path traversal and content-changing queries are rejected. External CDN invalidation remains separate.