All 12 Dark Mode sections

See every section

Caching

Updated Dark Mode 1.8.0Tested with WordPress 7.1

It works with a page cache, because the decision is made in the browser rather than on the server: every visitor gets the same HTML, and their own choice is applied before the page is painted. Nothing needs excluding from your cache, and usage statistics keep counting on pages served from it, however long ago the page was cached. The one exception is a Display Rules schedule saved before version 1.2.14 (see Display Rules).

What a cached page does keep is your settings: the few lines in its head that decide before the first paint carry the starting mode, the dark hours, the screen sizes and the colours, and the page carries the button. So saving a change your visitors would see asks your page cache to empty once the save is done. It asks at these other moments too:

  • when you switch the plugin off, at once, so visitors do not keep dark mode and its button from cached pages (switched off for a whole network, see Multisite);
  • on the first request after an update, or after you switch the plugin back on, that is not answered from the cache (a signed-in visit to your dashboard is one);
  • when you save your styles in the Site Editor while dark mode is on, since the theme's dark style is worked out from them;
  • when you delete the image chosen as the dark logo from the Media Library.

The caches it asks are NimbleCache, WP Rocket, WP Super Cache, W3 Total Cache, LiteSpeed Cache, WP Fastest Cache, SiteGround Speed Optimizer, Breeze, WP-Optimize, WP Engine's cache and Cloudflare's own plugin. A cache it cannot ask, such as your host's own or a CDN in front of the site, keeps the pages it has until they expire: empty it yourself after changing a setting. Another plugin, or your host, can listen for trdm_purge_caches to empty its own at the same moment. LiteSpeed Cache is asked for its pages only: its CSS and JS files, the object cache and Cloudflare stay as they are.

It also works in a browser that blocks cookies and site data. Nothing can be remembered there, so each page follows the device setting and your schedule, and the switch still works on the page it is pressed on.

The script, stylesheet and engine carry a version number, so an update reaches visitors and CDN edges straight away rather than when their copy expires.

Still stuck? Ask the developers who wrote it. We aim to reply within one business day.