Handle errors, 404s, and completion markers
POM Cache excludes fatal, incomplete, and most error-like responses by default. Extensions should preserve that conservative behavior unless an error page has a deliberate freshness and invalidation strategy.
wp_die() responses
When POM Cache's wp_die handling is selected, pom_cache_disable_cache_on_wp_die defaults to true. POM Cache then defines DONOTCACHEPAGE.
add_filter( 'pom_cache_disable_cache_on_wp_die', '__return_true' );
There is usually no reason to add this callback because it restates the default. The hook exists for exceptional integrations, but returning false can allow a failure or authorization response to proceed toward normal cache evaluation. Do not disable the safeguard globally to cache a custom public page; build that page through a normal WordPress route instead.
404 caching
Completed 404 HTML is not cached by default:
add_filter( 'pom_cache_404', '__return_false' );
To opt in:
add_filter( 'pom_cache_404', '__return_true' );
Enabling this is a site-wide policy. A cached “not found” page can hide content later published at the same URL until HTML and any CDN object are cleared.
Only enable 404 caching when:
- the 404 body is completely public and deterministic;
- no sensitive path details appear;
- publishing, restoring, importing, and changing permalinks clear the relevant cache;
- the CDN follows the same freshness policy;
- you have tested a URL that changes from missing to available.
The filter does not receive the requested path, so it is not a path-specific policy by itself.
Completion markers
Before writing, POM Cache matches the response against pom_cache_eof_tags. The default regular expression recognizes completed HTML, RSS, feed, URL-set, or XML output:
/(<\/html>|<\/rss>|<\/feed>|<\/urlset|<\?xml)/i
An integration that produces a different complete public format can extend the expression:
add_filter(
'pom_cache_eof_tags',
static function ( $pattern ) {
return '/(<\\/html>|<\\/rss>|<\\/feed>|<\\/urlset|<\\?xml|<\\/catalog>)/i';
}
);
Return a complete valid regular expression, including delimiters and modifiers. Do not concatenate unescaped user input into it.
Adding a weak marker such as a common <div> or a single closing brace can allow truncated responses to be cached. The marker should prove that the intended document finished rendering.
Other exclusions still apply
Passing the completion check or enabling 404s does not bypass:
- request-method checks;
- query and preview exclusions;
- REST, feed, robots, redirect, or response-type classification;
- bypass cookies;
DONOTCACHEPAGE;- master runtime settings;
- fatal-error detection;
- non-empty buffer requirements.
Test errors with the exact status code, headers, and body. A browser that displays an attractive error document can still be returning a redirect, CDN-generated page, or wrong HTTP status.