Table of Contents
How to cache table data and update the cache automatically in wpDataTables
Say your price list is a CSV file with 20,000 rows, and the page with the table takes seconds to load, because wpDataTables reads the whole file on every visit. With caching on, wpDataTables saves the data in the database once and loads the table from there. If the file changes every day, a scheduled job refreshes the cache for you.
Which tables can use the cache?
How do I turn on the cache for a table?
Open the linked table in the editor, turn on Cache data from source in the Data source tab and click Save Changes.
- Open the table. Go to wpDataTables → wpDataTables and open the linked table.
- Turn on the cache. In the Data source tab, under Cache data, turn on Cache data from source. It is off by default.
- Save the table. Click Save Changes. wpDataTables saves the data in the database and loads the table from the cache from now on.
The cache now holds the data from the moment you saved. Changes in the source file don’t show until the cache is updated, so this is enough for files that rarely change.

How do I update the cache automatically?
Turn on Enable for all non-server side tables under Auto update cache for tables in the settings, turn on Auto update cache in the table, and set up a cron job that calls the update URL on a schedule.
- Turn on auto update. Go to wpDataTables → Settings → Cache settings and, under Auto update cache for tables, turn on Enable for all non-server side tables. Click Save Changes. The tab now shows the cron instructions with your cache verify string.
- Turn it on in the table. Open the table, reload the page, and in the Data source tab turn on Auto update cache. It appears after you turn on Cache data from source. Click Save Changes.
- Schedule the update. Add a cron job on your server, or in a cron plugin, as described below.

How do I set up the cron job on my server?
Add a line to your server’s crontab that requests the update URL with your site address and your cache verify string. This line runs every 15 minutes:
*/15 * * * * wget -q -O - "https://your.website.url/wp-admin/admin-ajax.php?action=wdtable_update_cache&wdtable_cache_verify=your.cache.verify.string"
If your server has no wget, use curl:
*/15 * * * * curl -s "https://your.website.url/wp-admin/admin-ajax.php?action=wdtable_update_cache&wdtable_cache_verify=your.cache.verify.string" > /dev/null
How do I schedule the update without server access?
Use the free WP Crontrol plugin to call the update URL from WordPress itself.
- Add a schedule. After you install WP Crontrol, add a schedule of 15 minutes in its Cron Schedules screen.
- Add the event. Go to Tools → Cron Events, click Add Cron Event and choose URL cron event.
- Fill in the details. Paste the update URL with your site address and verify string, set the next run a few minutes from now, and choose the 15-minute schedule as the recurrence.
- Save the event. Click Add Event.
WordPress runs its cron events when someone visits the site, so on a quiet site the update can start later than planned.
Why does the cache not update?
The cache update stops when the source no longer matches the table. Check the source for these problems:
| Problem | Fix |
|---|---|
| The number of columns changed | Restore the columns, or create the table again. |
| Column names changed | Restore the names, or create the table again. |
| The source is empty | Add the data back to the file. |
| The file or URL no longer exists | Put the file back under the same URL. |
| Reading the file or URL fails | Open the URL in a browser and check the server’s error log. |
You’ll find more troubleshooting steps at the bottom of the Cache settings tab.
What should I remember about table caching?
Turn on Cache data from source in a linked table to load it from the database instead of the source. To keep it fresh, turn on Enable for all non-server side tables in Cache settings and Auto update cache in the table, then schedule the update URL with a server cron job or WP Crontrol. The update stops if the source’s columns change or the file is missing.
Where can I read more?
These pages cover the sources that use the cache: