Using JobRelay with caching Plugins

In this article

JobRelay works well with WordPress caching plugins, but there is one important consideration: your cache needs to be cleared when new jobs arrive. Otherwise, visitors may continue to see an outdated list of jobs.

This page explains why cache clearing matters and outlines the recommended approaches for keeping job listings fresh.

Why cache clearing is required

Most WordPress caching plugins (page cache, full‑page cache, static HTML cache, etc.) store a snapshot of your pages to improve performance. When JobRelay imports new jobs:

To avoid this, the cache must be cleared (or bypassed) when new jobs are imported.

The safest approach is to clear the cache automatically after JobRelay finishes adding, removing or updating jobs.

Most popular caching plugins support programmatic cache clearing, for example:

JobRelay exposes WordPress hooks that can be used to trigger cache clearing once an import completes.

Why this works well

Option 2: Exclude job listing pages from cache

Some sites choose to exclude job listing pages (or job search results) from caching entirely.

Typical exclusions include:

Pros

Cons

This approach is usually best for small sites or low‑traffic job listings.

Option 3: Use short cache lifetimes

You can configure your cache to expire job page caches quickly (for example, every 5–10 minutes).

Pros

Cons

This option is acceptable if near‑real‑time updates are not critical.

Clearing cache via JobRelay hooks

JobRelay provides action hooks that fire after a successful import. These can be used to clear caches automatically.

Example use cases:

Your developer can connect JobRelay’s import completion hook to the cache‑clearing function provided by your caching plugin.

Below is a simple code snippet to start you off.

<?php
/**
 * Clears the job cache.
 * 
 * @param  integer $job_post_id The newly created post ID for the new job.
 * @param  array   $job_data    The array of job data sent over.
 */
function hd_clear_cache_after_job_added_updated( $job_post_id, $job_data ) {

	/**
	 * Run your cache clearing code here.
	 */
	

}

add_action( 'jobrelay_wpcon_job_inserted_complete', 'hd_clear_cache_after_job_added_updated', 999, 2 );

In the part of the code above where it states “run your cache clearing code here“, this is where you would call the specific function for clearing the cache depending on which caching plugin you are using.