How to Automate Cache Purging and Preloading with Super Page Cache

Automating cache purging and preloading ensures your website always delivers updated and cached content without manual intervention. The Super Page Cache plugin provides a straightforward way to achieve this using cron jobs. Follow the steps below to configure automation for your site.

Introduction to Cron Jobs

WordPress real cron job refers to a method of scheduling and executing tasks, such as updating plugins, sending email notifications, or performing other automated actions, within a WordPress website.


Automating Cache Preloading with a Cron Job

To automate the preloading/purging process at intervals of your choice, you can set up a cron job to trigger the automatic purge/preloading URL provided by the plugin.

1

Navigate to the wp-config.php file, which is located in the root of the folder where WordPress is installed.

2

Insert the following code on a new line after define('WP_DEBUG', false);:

define('DISABLE_WP_CRON', true);
	

If you are not sure how to navigate to this file via your cPanel or FTP, install a plugin like File Manager Advanced to edit it directly from within WordPress.

Setting Up the Cron Job

Use your hosting provider's control panel or server management tool to create a cron job. Add the following command to hit the preloader URL at your desired intervals:

<code>curl -X GET "https://yourwebsite.com?swcfpc-purge-all=1&swcfpc-sec-key=CronJobSecretKey"

Replace https://yourwebsite.com?swcfpc-purge-all=1&swcfpc-sec-key=CronJobSecretKey with the actual preloader URL provided by the plugin.

  • For example, to run the preloader every hour, use the following command:
<code>0 * * * * curl -X GET "https://yourwebsite.com?swcfpc-purge-all=1&swcfpc-sec-key=CronJobSecretKey"

Testing the Cron Job

Verify that the preloading is working by checking the plugin logs or monitoring server activity. You can also manually test by visiting the preloader URL in a browser or via a Test Run button.


Automating Cache Purging via cPanel

Automating cache purging ensures outdated content is promptly removed. If you are using cPanel, you can create a true cron job to achieve this.

📝 Note: HostGator provides a detailed guide on how to create a true cron job. You can view their guide here: How to Create a True Cron for WordPress. The steps may vary slightly depending on your hosting provider.

If you are not comfortable setting up a cron job, contact your web host for assistance. A recommended interval is once every 10 minutes.

Alternative Method: Online Cron Job Services

1

Go to console.cron-job.org/signup and create an account.

2

Log in and open the Cronjobs panel. Click on Create Cronjob.

3

Fill out the details:

  • For Title, enter a descriptive name.
  • For URL, use https://yourwebsite.com?swcfpc-purge-all=1&swcfpc-sec-key=CronJobSecretKey
4

Set the execution schedule according to your needs (e.g., every 10 minutes).

Automating cache purging and preloading ensures your website remains fast and updated with minimal manual effort.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us