SWIS Overrides

There are a handful of settings not yet available in the UI. Additionally, if you would like to use SWIS on multi-site, you'll notice there isn't a network-wide settings page. That's on purpose, because overrides let you set network-wide defaults, but only for the settings you want. If you prefer to configure certain settings per-site, you can do that just fine. No need for any complicated logic. Anything that you don't define in your wp-config.php will be configurable on the single-site settings.

Let's see an example of how this works. To override anything within SWIS Performance, you define a "constant" in your wp-config.php file. This is the file where your database connection details are stored, as well as a few other settings that are global within WordPress. The wp-config.php file is located right in the root of your WordPress install folder, often right inside the public_html folder or a similar location.

Defining a constant looks something like this:

define( 'SWIS_CACHE_EXPIRES', 24 );

Important: For all overrides, make sure that you insert the define above where your wp-config.php file says to stop editing. You'll see something like "That's all, stop editing!". Adding anything below that line will not have any effect. Also, make sure you do not use quotes around boolean (true/false) and numerical values or this will turn them into strings, like 'something', 'false', or '8'.

Here are all the available overrides (with examples):


define( 'SWIS_DEBUG', true );


define( 'SWIS_CACHE', true );


define( 'SWIS_CACHE_EXPIRES', 24 );

SWIS_CACHE_CLEAR_COMPLETE_CACHE_ON_CHANGED_PLUGIN - enabled by default, and clears the whole cache when a theme, plugin, or core upgrade is completed and if a plugin is activated/deactivated.


SWIS_CACHE_CLEAR_COMPLETE_CACHE_ON_SAVED_POST - disabled by default, and clears the whole cache when a post/page is published/modified instead of just the home page and individual page.


SWIS_CACHE_CLEAR_COMPLETE_CACHE_ON_SAVED_COMMENT - disabled by default, and clears the whole cache when a comment is added, deleted, updated, etc. instead of just the individual page where the comment was written.


SWIS_CACHE_MOBILE - disabled by default, and generates separate cache files for detected mobile devices.

NOTE: This option is only helpful if your site delivers unique HTML to mobile devices. IF this option is enabled unnecessarily, it will harm cache performance.

define( 'SWIS_CACHE_MOBILE', true );

SWIS_CACHE_WEBP - disabled by default, and generates separate cache files for browsers that support WebP images.

define( 'SWIS_CACHE_WEBP', true );

SWIS_CACHE_EXCLUSIONS - this uses simple string matching, no wildcards needed, and no regex syntax.

define( 'SWIS_CACHE_EXCLUSIONS', array( '/thing1/', '/thing2/' ) );

SWIS_CACHE_EXCLUDED_COOKIES - this must be a valid regex, the default is shown below. Any visitor that has a matching cookie will bypass the cache.

define( 'SWIS_CACHE_EXCLUDED_COOKIES', '/^(wp-postpass|wordpress_logged_in|comment_author|edd_cart_messages|edd_items_in_cart|edd_saved_cart|woocommerce_items_in_cart|wp_woocommerce_session)/' );

SWIS_CACHE_EXCLUDED_QUERY_STRINGS - this must be a valid regex, the default is shown below. A list of GET/query parameters for caching. Note the default regex has parameters that are allowed first, and then a list of disallowed query strings.

define( 'SWIS_CACHE_EXCLUDED_QUERY_STRINGS', '/^(?!(fbclid|ref|mc_(cid|eid)|utm_(source|medium|campaign|term|content|expid)|gclid|fb_(action_ids|action_types|source)|age-verified|usqp|cn-reloaded|_ga|_ke)).+$/' );


define( 'SWIS_CACHE_PRELOAD', true );

To exlude files from preloading, use the swis_skip_cache_preload filter to skip selected pages. The first argument defaults to false, return true to skip the given page. The second argument is the page URL.

SWIS_CACHE_PRELOAD_DELAY - by default, SWIS will wait 5 seconds between requests in order to avoid a server overload. You may with to have it go faster if your server has sufficient resources. Alternatively, you may use the 'swis_cache_preload_delay' filter.


SWIS_CACHE_PRELOAD_SITEMAP - specify your own sitemap(s) to use for preloading. By default, SWIS looks for sitemap_index.xml, sitemap.xml, and wp-sitemap.xml. But if you have a sitemap located elsewhere, you can tell SWIS to use that instead. You can provide either a single URL, or an array of sitemap URLs. Alternatively, use the swis_cache_preload_default_sitemaps filter.

define( 'SWIS_CACHE_PRELOAD_SITEMAP', 'https://example.com/my-sitemap.xml' );

SWIS_CACHE_PRELOAD_FRONT_PAGE_AUTO - when the preloader is used with our cache, everything is automatic. But if you are using a third-party/server-based page cache, this option will trigger the preload process any time an uncached home/front page is encountered. Use with caution, as short cache lifetimes will cause the preloader to run constantly.



define( 'SWIS_DEFER_CSS', true );


define( 'SWIS_MINIFY_CSS', true );


define( 'SWIS_DEFER_JS', true );


define( 'SWIS_MINIFY_JS', true );


define( 'SWIS_OPTIMIZE_FONTS', true );

SWIS_SLIM_DISABLE_FRONTEND_MENU - The SLIM module adds information to each page when so you can see what JS/CSS files are loading as a logged-in admin. But if you need to suppress the HTML and front-end functions from the SLIM module, you may do so with this override.


SWIS_CONTENT_DIR - By default, SWIS will attempt to store cache files for various functions in wp-content/swis/, but if that doesn't work for your site, you can tell SWIS to use a different folder. For example, somewhere in the uploads/ folder, like this:

define( 'SWIS_CONTENT_DIR', '/var/www/mysite.com/wp-content/uploads/swis/' );

*Be sure to include the trailing slash, or weird things will happen, like pigs flying!

Still need help? Contact Us Contact Us