Getting Started

Choose the right plan

Swift Performance is the best choice to speed up your WordPress sites. There are 4 + 1 available plans:

Single plan

You can use Swift Performance with Single plan for 1 WordPress site. It can be the right choice if you have only 1 site, or if you would like to test what can Swift Performance do (you can upgrade your subscription later).

Multi plan

You can use Swift Performance with Multi plan for up to 5 WordPress sites. Regarding that the Multi plan price is very reasonable, if you have at least 2 sites you should choose Multi plan.

Developer plan

As the plan name suggest this plan is the best for developers, who manage many sites. You can use Developer Plan for up to 30 WordPress sites. If you are an agency, or freelancer, who has few clients you should choose Developer plan.

Business plan

We created Business plan for professional speed up experts, who doesn't manage the site, but speed up WordPress sites as a service. Business plan can be used on unlimited sites. For this plan monthly subscription is also available, so you can choose the monthly plan with a reasonable monthly fee as well.

Micro plan

Micro license is a special Single license for bloggers and personal sites. Even if your project generates some income you can use Micro license if your project meets the following requirements: Your site may can generate income from ads, but you can't sell any service/product (including PR articles) on the site. Using Micro license is not allowed for politically active sites.


Install Swift Performance

  1. Login to My account on musthaveplugins.com
  2. On the next screen you will see your subscriptions. Choose any active subscription and click to Manage Subscription
  3. On the next screen click to Download in Swift Performance section
  4. Login to WordPress admin where you would like to install Swift Performance
  5. Go to Plugins > Add new and click to upload plugin
  6. Select the previously downloaded ZIP file and click to install
  7. Now let Swift Performance to configurate itself

Basic configuration

Caching

What is Caching?

Caching is the core performance optimization in Swift Performance. Instead of executing PHP code and database queries on every page request (which takes 200-800ms), Swift Performance creates static HTML files that can be served in just 5-15ms – a 40-160x speed improvement.

How the Cache Engine Works

The caching process follows this lifecycle:

  1. Request Arrives – Swift Performance checks if caching is enabled and if the request is cacheable (not POST, not admin, not logged-in unless Logged-in Cache is enabled)
  2. Cache Load Attempt – Checks /wp-content/swift-ai/cache/{domain}/{path}/__index/ for existing cache file
  3. Cache Hit – If found, serves static file immediately with Swift3: HIT header
  4. Cache Miss – If not found, WordPress generates the page normally while Swift Performance captures the output
  5. Output Buffering – Uses ob_start() to capture the generated HTML
  6. Cacheability Check – Validates the content is cacheable (not password-protected, not 404, not excluded)
  7. Cache Save – Writes HTML to __index/index.html and metadata to __data/data.json
  8. Warmup Queue – Adds URL to optimization queue for image/CSS/JS optimization

Page Priority System

Swift Performance uses a smart priority system that automatically optimizes your most important pages first.

How It Works:

  • Initial priorities are assigned based on page type (homepage = highest, blog posts = lower)
  • Real visitor data automatically adjusts priorities – most visited pages become more important
  • Adapts to changes – priorities reset weekly to reflect current traffic patterns

Real-World Examples:

  • Marketing campaign: A new landing page with high traffic automatically becomes high priority for optimization
  • Low traffic: A Terms & Conditions page with few visits automatically becomes lower priority
  • Main Thread: Swift Performance focuses optimization resources on your most popular pages (typically top 10%)

Result: You don't need to manually configure priorities – Swift Performance automatically optimizes what matters most to your visitors.

Cache Invalidate vs Purge

Operation When It Happens What It Does Visitor Experience
Invalidate Post updated, comment added, menu changed, theme/plugin updated
  • Marks page as stale (status -4)
  • Queues page for re-optimization
  • Does NOT delete cache file
  • Cache file remains until rebuild completes
Zero downtime: Visitors continue seeing cached content during rebuild process
Purge Post deleted, manual clear via toolbar, development mode activated
  • Immediately deletes cache file
  • Resets status to 0 (needs caching)
  • Optionally removes from warmup queue (if $remove_warmup = true)
  • Triggers CDN purge (Cloudflare/Varnish/LiteSpeed)
Visitors get fresh (uncached) content immediately, may experience slower page load until cache rebuilds

Key Difference: Invalidate keeps visitors happy with cached content while rebuilding in the background. Purge forces immediate fresh content at the cost of temporary performance.

Automatic Cache Management Triggers

Swift Performance automatically manages cache based on WordPress actions:

Invalidate (Zero Downtime - Cache Remains):

  • save_post – Post or page updated (also invalidates homepage and related archives)
  • pre_post_update – Before post update
  • wp_set_comment_status – Comment approved/unapproved
  • after_switch_theme – Theme changed (invalidates all pages)
  • customize_save_after – Customizer settings saved (invalidates all pages)
  • wp_update_nav_menu – Navigation menu updated (invalidates all pages)
  • update_option_sidebars_widgets – Widgets changed (invalidates all pages)
  • activated_plugin / deactivated_plugin – Plugin status changed (invalidates all pages)
  • upgrader_process_complete – WordPress/plugin/theme updated (invalidates all pages)

Purge (Immediate Deletion - Cache Removed):

  • delete_post – Post or page deleted (purges that page, invalidates homepage and archives)
  • wp_trash_post – Post moved to trash (purges that page, invalidates homepage and archives)
  • delete_attachment – Media file deleted (purges that page, invalidates homepage and archives)
  • save_post – For the specific updated post (purges old version, invalidates related pages)

Smart Invalidation: When a post is updated, Swift Performance also invalidates:

  • Homepage (if post appears in recent posts)
  • All pages containing loops with that post type
  • Category/tag archives where the post appears
  • Author archives
  • Date-based archives
  • swift3_purge_cache action hook – Custom purge triggers

Nonce Handling in Cached Pages

WordPress nonces expire after 12-24 hours, which can cause "expired nonce" errors on cached pages. Swift Performance handles this in several ways:

  • Checksum Filtering – The swift3_checksum_source filter strips nonce values before calculating page checksums, preventing re-optimization when only nonces change
  • Fragment Strategy – Wrap forms containing nonces in fragments so they load fresh via AJAX on every page view
  • Collage for Logged-in Users – Enable Collage to load user-specific content (including nonces) dynamically while serving cached pages
  • Exclude Sensitive Pages – Use swift3_is_url_excluded filter or Exclude URLs setting to bypass caching for pages with critical forms
  • Nonces in cached pages remain valid for their full lifespan (24 hours by default)

When to Use Caching

Issue Solution
Managed hosting with built-in page caching (Kinsta, WP Engine, etc.) Disable Swift Performance caching to avoid conflicts
Highly personalized sites where every user sees different content Disable caching or use Logged-in Cache for logged-in users
Development/staging environments Use Development Mode instead of caching
Sites with real-time data that must never be stale Disable caching or use Exclude URLs for specific pages

Available Hooks & Constants

Filters: swift3_is_request_cacheable, swift3_is_page_cacheable, swift3_cache_buffer, swift3_cache_basedir, swift3_checksum_source

Actions: swift3_cache_done, swift3_page_discovered, swift3_invalidate_cache, swift3_purge_cache

Constants: SWIFT3_CACHE_LIFESPAN, SWIFT3_SEPARATE_DEVICES, INVALIDATE_CACHE_ON_COMMENT

See Developers section for detailed hook documentation and examples.


Optimize CSS

What is Critical CSS?

Critical CSS is the minimum CSS needed to render the above-the-fold content (what users see without scrolling). By inlining this CSS in the <head> and deferring the rest, pages render instantly without waiting for external stylesheets to download.

Impact: Improves First Contentful Paint (FCP) by 0.5-2 seconds and Largest Contentful Paint (LCP) by 0.3-1.5 seconds.

Optimization Levels

Level Features When to Use
0 - Disabled
  • No CSS optimization
  • All stylesheets load normally
Debugging CSS issues, development environment
1 - Basic
  • Critical CSS extraction
  • Unused CSS removal
  • CSS minification
  • Media query optimization
  • No font optimization
Custom fonts with licensing restrictions, icon fonts, sites with special characters (Chinese, Arabic, etc.)
2 - Full (Recommended)
  • Everything from Level 1, PLUS:
  • Font subsetting (only used characters)
  • WOFF2 conversion
  • Font preloading
  • font-display: swap
Recommended for 95% of sites – Maximum performance with standard Latin fonts

How CSS Optimization Works

Step 1: CSS Collection (During cache prebuild)

  • Swift Performance visits the page with a headless browser
  • Collects all <link rel="stylesheet"> and <style> tags
  • Sends CSS URLs and inline styles to the API

Step 2: API Processing

  • API renders page in Chrome (viewport: desktop 1441x721px, mobile 541x721px)
  • Uses CSS coverage analysis to identify above-the-fold styles
  • Generates device-specific critical CSS files
  • Level 2 only: Analyzes used characters and creates subset fonts

Step 3: Delivery

  • Critical CSS inlined in <head> with media queries:
    • @media (min-width: 768px) for desktop
    • @media (max-width: 767px) for mobile
  • Original stylesheets changed to rel="swift/stylesheet"
  • Full stylesheets load after page renders (via JavaScript)
  • Level 2: Fonts preloaded with <link rel="preload" as="font">

Font Optimization (Level 2)

Character Detection:

The API scans your page HTML and extracts all used characters. For example, if your page only uses "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,!? ", only these characters are included in the subset font.

Before Optimization:

@font-face {
    font-family: 'MyFont';
    src: url('/fonts/myfont.woff2');
    /* File size: 150KB, contains 5000+ characters */
}

After Optimization (Level 2):

@font-face {
    font-family: 'MyFont';
    src: url('/wp-content/swift-ai/cache/.../abc123.woff');
    /* File size: 8KB, contains only 80 used characters */
    font-display: swap;
}

File Size Reduction: Typically 85-95% smaller (150KB → 8KB)

Troubleshooting

Issue Solution
Missing font characters Set to Level 1, or ensure all used characters are in page content during optimization
External CSS not optimized Ensure CSS is from same domain or CORS-enabled
Layout shifts (CLS) Enable Optimize CLS feature
Icon fonts broken Use Level 1 or exclude icon font via swift3_before_assets_optimizer filter

Available Hooks & Constants

Filters: swift3_skip_optimizer, swift3_before_assets_optimizer, swift3_after_assets_optimizer, swift3_css_layer

Constants: LEGACY_CCSS (force old critical CSS version)

See Developers section for code examples.


Optimize JS

One of the best improvements in Swift Performance is the real javascript optimization. If this feature is enabled Swift Performance will optimize javascript execution and decrease the load on main browser thread. It can speed up your site even for logged in users and on non-cached pages.


JS Delivery

What Does "Offload the Main Thread" Mean?

The main thread is the browser's UI thread that handles rendering, user interactions, and JavaScript execution. When the main thread is busy executing JavaScript, the page becomes unresponsive – users can't click, scroll, or interact.

"Offloading the main thread" means deferring non-critical JavaScript execution until:

  • The page has finished rendering (DOMContentLoaded)
  • The browser is idle (requestIdleCallback)
  • The user interacts with the page (scroll, click, touch)

Impact: Reduces Time to Interactive (TTI) by 30-60% and Total Blocking Time (TBT) by 40-70%.

What is "Delay JS"?

Delay JS means converting <script> tags to <script type="swift/javascript"> so they don't execute immediately. Swift Performance's custom loader then executes them at the optimal time based on:

  • Priority – Critical scripts load first, analytics/tracking scripts load last
  • Dependencies – jQuery loads before jQuery plugins
  • User interaction – Some scripts wait for user activity
  • Browser idle time – Low-priority scripts use requestIdleCallback

Optimization Levels

Level Behavior When to Use
0 - Disabled
  • All scripts load normally
  • No delivery optimization
Debugging JavaScript issues, incompatible theme
1 - Medium (Safe)
  • Load on user interaction (scroll, click, touch)
  • Respects script dependencies
  • Preserves jQuery inline code
  • Fallback timeout: 3 seconds
Recommended for e-commerce, membership sites, forms-heavy sites
2 - Aggressive (Maximum Performance)
  • Everything from Level 1, PLUS:
  • Uses requestIdleCallback for idle-time loading
  • More aggressive script deferring
  • Strict execution order enforcement
  • Fallback timeout: 2 seconds
Recommended for blogs, corporate sites, landing pages

How It Works

Step 1: Script Detection

Swift Performance converts all <script> tags to <script type="swift/javascript"> and moves src to data-src:


<script src="/path/to/script.js"></script>


<script type="swift/javascript" data-src="/path/to/script.js"></script>

Step 2: User Interaction Detection (Level 1)

// Wait for user interaction
['touchstart', 'mousemove', 'scroll', 'keydown', 'click'].forEach(function(event) {
    document.addEventListener(event, function() {
        loadDeferredScripts(); // Execute all delayed scripts
    }, {once: true, passive: true});
});

// Fallback after 3 seconds if no interaction
setTimeout(loadDeferredScripts, 3000);

Step 3: Idle Time Loading (Level 2)

// Use browser idle time
if ('requestIdleCallback' in window) {
    requestIdleCallback(function() {
        loadDeferredScripts();
    }, {timeout: 2000});
} else {
    setTimeout(loadDeferredScripts, 1);
}

Step 4: Dependency Management

Swift Performance automatically detects jQuery dependencies and loads jQuery before inline jQuery code:

// Detects this pattern
<script>
jQuery(document).ready(function($) {
    $('.slider').slick(); // Requires jQuery
});
</script>

// Ensures jQuery loads first, then executes inline code

Performance Impact

Metric Before Level 1 Level 2
Time to Interactive (TTI) 4.2s 2.8s (33% faster) 2.1s (50% faster)
Total Blocking Time (TBT) 890ms 320ms (64% reduction) 180ms (80% reduction)

Compatibility Testing Checklist

Before enabling Level 2, test these scenarios:

  • Forms submit properly (contact forms, search forms)
  • Sliders/carousels initialize correctly
  • Modal popups open/close
  • AJAX functionality works (add to cart, filters)
  • Video players load (YouTube, Vimeo)
  • Image galleries function
  • Dropdown menus operate
  • Social sharing buttons work
  • Live chat widgets load
  • Analytics tracking fires
  • Cookie consent notices appear
  • Payment gateways function (checkout process)

Troubleshooting

Issue Solution
Forms don't submit Set to Level 1 or mark form scripts as critical using swift3_before_assets_optimizer filter
Sliders don't work Scripts may need to be marked as critical – see Developers section
Console errors about jQuery Swift Performance auto-detects jQuery dependencies, but some plugins may need manual exclusion
Third-party widgets broken Use swift3_skip_js_optimization filter to exclude specific scripts

Available Hooks & Constants

Filters: swift3_skip_js_optimization, swift3_js_delivery_tag, swift3_script_type, swift3_before_assets_optimizer

See Developers section for code examples on excluding specific scripts.


Optimize Images

Swift Performance will generate optimized WebP version for all images (including third party and background images) on the fly. Optionally you can also enable Optimize Images on Upload. Swift Performance also can use WebP which has been generated by other plugins, so you can switch instantly.

Optimize Iframes

What It Does

Replaces heavy iframes (YouTube videos, Google Maps, embedded widgets) with optimized placeholders and lazy-loads the actual iframe content only when needed. This can improve LCP by 1-3 seconds and reduce initial page weight by 500KB-2MB per iframe.

Optimization Levels

Level What It Does When to Use
0 - Disabled
  • All iframes load immediately
  • No optimization applied
  • Full iframe content downloads on page load
Debugging iframe issues
1 - Basic Lazy Loading
  • Converts src to data-src
  • Sets loading="lazy" attribute
  • Iframe loads when entering viewport
  • YouTube gets enablejsapi=1 automatically
  • No placeholder screenshots
Basic optimization without screenshots
2 - Full Optimization (Recommended)
  • Everything from Level 1, PLUS:
  • API generates optimized WebP screenshot
  • Click-to-play functionality
  • Iframe only loads if user clicks
  • Significantly faster LCP
Recommended for 95% of sites – Maximum performance

HTML Transformation

Before Optimization:

<iframe src="https://www.youtube.com/embed/ABC123"></iframe>

After Level 1:

<iframe src="" 
        data-src="https://www.youtube.com/embed/ABC123?enablejsapi=1" 
        loading="lazy"></iframe>

After Level 2:

<div class="swift3-iframe-placeholder" 
     data-src="https://www.youtube.com/embed/ABC123?enablejsapi=1">
    <img src="/wp-content/swift-ai/cache/.../iframe-screenshot.webp">
    <button class="play-button">▶</button>
</div>

How to Exclude Specific Iframes

Method 1: Exclude by URL Pattern (Recommended)

add_filter('swift3_avoid_lazy_iframes', function($list) {
    // Exclude payment gateway iframes
    $list[] = 'paypal.com';
    $list[] = 'stripe.com';
    
    // Exclude booking systems
    $list[] = 'calendly.com';
    $list[] = 'booking.com';
    
    return $list;
});

Method 2: Exclude by HTML Attributes

add_filter('swift3_skip_iframe_optimization', function($skip, $tag) {
    // Exclude iframes with specific class
    if (isset($tag->attributes['class']) && 
        strpos($tag->attributes['class'], 'no-lazy') !== false) {
        return true; // Skip optimization
    }
    
    // Exclude iframes by data attribute
    if (isset($tag->attributes['data-critical'])) {
        return true;
    }
    
    return $skip;
}, 10, 2);

Method 3: Disable on Specific Pages

add_filter('swift3_skip_optimizer', function($skip) {
    // Disable all optimization (including iframes) on landing pages
    if (is_page('landing-page')) {
        return true;
    }
    return $skip;
});

Automatic Exclusions

Swift Performance automatically excludes these iframes from optimization:

  • google.com/recaptcha/ – Google reCAPTCHA
  • hotjar.com – Hotjar analytics
  • Payment gateways on checkout pages (WooCommerce, SureCart)
  • Iframes with display:none or width: 0-1px
  • Iframes with src="about:blank"

Performance Impact

Real-world metrics from production sites:

  • LCP improvement: 1.2s to 2.8s reduction (embedding YouTube videos)
  • Page weight: 800KB to 1.5MB reduction per embedded video
  • Initial requests: 15-25 fewer HTTP requests on page load
  • TTI improvement: 500ms to 1s faster Time to Interactive

Troubleshooting

Issue Solution
Iframe doesn't load at all Check browser console for JavaScript errors. Verify REST API is accessible.
Payment gateway not working Already excluded on checkout pages. If issue persists, use Method 1 to exclude specific gateway.
Interactive map broken Consider using Level 1 instead of Level 2, or exclude specific map provider.
reCAPTCHA doesn't appear Already excluded automatically. Check if other optimization is interfering.

Available Hooks & Constants

Filters: swift3_skip_iframe_optimization, swift3_avoid_lazy_iframes, swift3_skip_optimizer

See Developers section for detailed hook documentation and examples.

Code Optimizer

What It Does

Selectively disables plugins on pages where they're not needed, reducing HTTP requests, database queries, PHP execution time, and memory usage. For example, WooCommerce can be disabled on blog posts, or Yoast SEO can be disabled on the frontend.

How It Works

  1. Plugin Detection – Identifies the current context (admin, frontend, AJAX, REST API)
  2. Rule Application – Applies intelligent rules to determine which plugins are needed
  3. Temporary Deactivation – Removes plugins from active_plugins option temporarily
  4. Restoration – Restores original plugin list after WordPress loads

Built-in Optimizations

  • Admin Cache – Caches admin page HTML, saves 200-500ms per admin page load
  • Heartbeat Control – Reduces WordPress heartbeat frequency to save server resources
  • Emoji Script Removal – Removes emoji detection script (saves 1 HTTP request)

Implemented Plugin Optimizations

Swift Performance includes intelligent rules for these popular plugins:

Plugin Optimization Rule
Elementor Disabled on non-Elementor pages, enabled only when editing or viewing Elementor content
WooCommerce Disabled on non-shop pages (blog posts, static pages without products)
Yoast SEO Disabled on frontend, enabled only in admin for SEO configuration
Rank Math Disabled on frontend, enabled only in admin
Contact Form 7 Disabled on pages without CF7 shortcodes
Ninja Forms Disabled on pages without Ninja Forms
WPForms Disabled on pages without WPForms shortcodes
Revolution Slider Disabled on pages without Revolution Slider
NextGEN Gallery Disabled on pages without gallery shortcodes
The Events Calendar Disabled on non-event pages
Mailchimp Disabled on pages without Mailchimp forms
Duplicator Disabled on frontend, enabled only in admin
All-in-One WP Migration Disabled on frontend, enabled only in admin
Broken Link Checker Disabled on frontend, enabled only in admin
Duplicate Post/Page plugins Disabled on frontend, enabled only in admin

Important: Potential Plugin Dependency Issues

Warning: Code Optimizer can cause issues if one plugin tries to use functions from another plugin that has been disabled on that page.

Example scenario:

  • Plugin A is disabled on the current page
  • Plugin B tries to call a function from Plugin A
  • Result: Fatal error or broken functionality

If you encounter such issues:

  1. Note which plugins are involved
  2. Report the issue to Swift Performance support
  3. Our development team will implement a fix to handle the dependency
  4. As a temporary workaround, you can disable Code Optimizer or exclude specific plugins

Adding Custom Rules

Example: Disable WooCommerce on Blog Posts

add_action('swift3_code_optimizer_before_check_plugin', function($plugin) {
    if ($plugin === 'woocommerce/woocommerce.php') {
        Swift3_Code_Optimizer::add($plugin, function() {
            // Disable on single blog posts
            if (is_single() && get_post_type() === 'post') {
                return true; // Disable
            }
            return false; // Keep enabled
        });
    }
});

Example: Disable Contact Form 7 Everywhere Except Contact Page

Swift3_Code_Optimizer::add('contact-form-7/wp-contact-form-7.php', function() {
    if (is_page('contact')) {
        return false; // Keep enabled
    }
    return true; // Disable everywhere else
});

Safety Features

  • Automatic Restoration – Original plugin list is restored after WordPress loads
  • Admin Access – Plugins always load in admin areas where they might be configured
  • Error Recovery – If a disabled plugin is needed, it will be automatically re-enabled on next request
  • Rescue Mode – If Code Optimizer causes issues, a rescue link appears on error pages to disable it

Performance Impact

  • Admin pages: 200-500ms faster load times with admin cache
  • Frontend: 100-300ms faster when heavy plugins are disabled
  • Memory usage: 10-30MB reduction per disabled plugin
  • Database queries: 5-20 fewer queries per disabled plugin

Available Hooks

Actions: swift3_code_optimizer_before_check_plugin

See Developers section for detailed examples.

Development Mode

Development Mode temporarily suspends caching and optimization features for two hours (unless disabled beforehand).

Advanced configuration

You can tweak advanced settings if you click "Under the hood" button in Configuration. In most cases you won't need to change these settings, except if you need a quick fix until permanent solution from our dev team.

Caching

Logged in cache

If you enable this option Swift Performance will serve cached pages even for logged in users. In most cases you can simply load cached pages for logged in users as well. If there are some parts which should be personalized, you can use fragments to load them AJAX, or enable Collage to automated detection.

Exclude URLs

With this option, you can exclude pages by URL (or URL part). Write one URL (part) per line, then click to update.

Swift Performance will detect non-cacheable pages automatically, however regarding that there are over 50 000 WordPress plugins and approximetly 30 000 themes, it can happen that Swift Performance can't detect a non-cacheable page. If you find that there is a plugin or theme related page which always should be excluded, please let us know.

Exclude Post Types

With this option, you can exclude post types. You can select multiple post types.

Just like pages, Swift Performance can detect non-cacheable post types automatically as well. However regarding that there are over 50 000 WordPress plugins, it can happen that Swift Performance can't detect a non-cacheable post type. If you find that there is a custom post type which always should be excluded, please let us know.

Query String

By default Swift Performance will bypass caching if query string is present in the URL. There are 2 options to overwrite this default behavior:

Ignored query parameters

You can define query parameters which should be ignored. Write one parameter per line. Swift Performance ignores some parameters by default: utm_source, utm_campaign, utm_medium, utm_expid, utm_term, utm_content, fb_action_ids, fb_action_types, fb_source, fbclid, _ga, gclid, age-verified

Allowed query parameters

You can list query parameters which shouldn't be ignored, but should be cached separately. For example if you add "s" parameter, all of your search results pages will be cached separately. Write one parameter per line.

Bypass Cookies

By default Swift Performance will bypass caching if some specific cookies are set. However you can list any cookies here.

If you find that there is a cookie, which always should be bypassed, please let us know.

Enable GZIP

Usually you won't need to enable GZIP manually, because Swift Performance can detect compression and configure it automatically. However if you have double GZIP issues, then you may need to disable this feature in Swift Performance settings.

Browser Cache

With this option you can let Swift Performance to set the expiry headers for different content types. Usually you don't need to disable this, however in some cases (for example if you are using a CDN with own expiry values), it is unnecessary.

Keep Original Headers

Send original headers for cached pages. If you are using a plugin which send custom headers you can keep them for the cached version as well.


Media

Optimize Images on Upload

Swift Performance will optimize all images (even third party, and background images) on demand. This means, when the cache warmer cache a page, it will pick up all images and optimize them on the actual page. Therefore you don't really need to optimize images on upload, however it can be useful if you would like to serve optimized images for the first (uncached) pageview.

Lazyload Images

Swift Performance is using the native lazyload for images, but improve it. Automatically detects important images and exclude them from lazyloading. You need disable this feature only if you would like to use a different plugin for lazyloading (not recommended).

Smart Image Sizing

Swift Performance will automatically resize images for every used viewport size, and will use responsive images on every pages (even for logged in visitors). You need disable this feature only if you would like to use a different plugin for responsive images (not recommended).

Optimize Rendering

Swift Performance will automatically detect the important images on every pages during the optimization process. These images will be excluded from lazyloading and will be preloaded (using the right responsive size) to improve LCP and FCP scores.


Fragments

General

Swift Performance can load some part of the page dynamically and load the rest from cache. You can enable fragment caching for Elementor Widgets or Gutenberg Blocks in the editor, and specify shortcodes which should be loaded dynamically.

Collage

Collage is a smart feature, which identify dynamic part of a page and load them via AJAX. It can be extremly helpful, if you also enable Logged in cache.


With this feature Swift Performance will use smart preload technique (based on network bandwidth and device) to speed up the onsite navigation. With preloading important pages before the user navigate the navigation can be nearly instant. It will improve the field data scores, and the user experience as well.

System

On the system tab you can see your subscription status and disconnect the current site from the subscription.

You can also enable/disable the optimization daemon, which is a background process, and responsible for the optimization process. In most cases you don't need to disable it, however if you are using a shared hosting with limited resources, you may need to disable it.

Integrations

General

Swift Performance is compatible with most plugins and themes out of box, however there are a few third-party plugins, themes, server software and services which are highly integrated with Swift Performance. Most of them doesn't need any configuration (like Elementor, Slider Revolution, WP Bakery, LiteSpeed, etc.), some others can be configured - if it is necessary.


Cloudflare

You can enable autopurge Cloudflare cache, which is recommended if you are using Cloudflare APO, or proxy caching. If you previously used any Cloudflare plugin where your API credentials were set, Swift Performance will find them so you don't need to set them again.

If Cloudflare couldn't be configured automatically you need to choose the authentication mode, and enter Cloudflare e-mail and API password, or Cloudflare API token (recommended).

Once you configured Cloudflare you can enable Proxy caching, which will provide the same performance as Cloudflare APO.


Nginx

If your site is running on Nginx server you need to add the generated rules manually to Nginx config.

You can find the rewrite rules on Nginx tab under Integrations, copy the rules, add them to config and restart Nginx.

On Nginx integration tab you can also verify that rules are up-to-date and working.


Varnish

If Swift Performance detects Varnish you can enable Varnish module on Varnish tab under Integrations. Once you enabled it, Swift Performance will manage Varnish cache as well.


WooCommerce

There are some specific features which can be enabled for a WooCommerce site. You can manage them on WooCommerce tab under Integrations.

Prebuild Variations

If you have separate single pages for variations you should also prebuild them. For this you need to enable Prebuild Variations feature, so Swift Performance will automatically preload, cache and optimize available variation single pages for all products.

Checkout Booster

Swift Performance can preload the checkout page and optimize AJAX fragments to keep the checkout experience fast.

Price Fragments

If you have a multi-currency store, or use visitors' geolocation to calculate VAT on shop/product pages, you can enable Price Fragments feature, to load prices via AJAX, while the rest of the page can be served from cache.

Developers

Swift Performance AI provides a comprehensive set of hooks and constants that developers can use to extend or modify its functionality. This section documents all available filter hooks, action hooks, and constants.

Filter Hooks

Filter hooks allow you to modify data or functionality. Here's a complete list of filter hooks available in Swift Performance AI. You can use these hooks in your theme's functions.php file or in a custom plugin.

Note: Filter hooks should be added using the add_filter() WordPress function. The general syntax is:

add_filter('hook_name', 'callback_function', priority, accepted_args);
where priority is optional (default: 10) and accepted_args is optional (default: 1).

swift3_litespeed_cache_rewrites

Controls whether LiteSpeed cache rewrites should be enabled in the .htaccess file. This filter determines if LiteSpeed caching directives are added to or removed from the .htaccess file.

Parameters:
  • $enabled (boolean) - Whether cache rewrites are enabled
Default:

Value of swift3_check_option('caching', 'on')

Example:
// Only enable LiteSpeed cache rewrites in production environment
add_filter('swift3_litespeed_cache_rewrites', function($enabled) {
    // Check for development environment
    if (defined('WP_ENVIRONMENT_TYPE') && WP_ENVIRONMENT_TYPE !== 'production') {
        return false;
    }
    return $enabled;
});
swift3_nginx_cache_rewrites

Controls whether Nginx cache rewrites should be enabled.

Parameters:
  • $enabled (boolean) - Whether cache rewrites are enabled
Default:

Value of swift3_check_option('caching', 'on')

Example:
// Only enable Nginx cache rewrites in production environment
add_filter('swift3_nginx_cache_rewrites', function($enabled) {
    // Check for development environment
    if (defined('WP_ENVIRONMENT_TYPE') && WP_ENVIRONMENT_TYPE !== 'production') {
        return false;
    }
    return $enabled;
});
swift3_deactivate_plugins

Filter the list of plugins to deactivate when there are overlapping functionalities.

Default list includes:

  • Swift Performance 2.x
  • W3 Total Cache
  • Autoptimize
  • WP Rocket
  • WP Fastest Cache
  • WP Super Cache
  • Hummingbird
  • SG Optimizer
  • Cache Enabler
  • Breeze
  • Nitropack
Parameters:
  • $plugin_files (array) - Array of plugin file paths to deactivate
Example:
// Keep Autoptimize active even when Swift Performance is active
add_filter('swift3_deactivate_plugins', function($plugin_files) {
    // Find and remove Autoptimize from the list of plugins to deactivate
    foreach ($plugin_files as $key => $plugin_file) {
        if (strpos($plugin_file, 'autoptimize') !== false) {
            unset($plugin_files[$key]);
        }
    }
    return $plugin_files;
});
swift3_varnish_detected

Allows modification of Varnish detection logic.

Parameters:
  • $detected (boolean) - Whether Varnish is detected
Default:

Based on HTTP_X_VARNISH header or VARNISH constant

Example:
// Force Varnish detection for specific environments
add_filter('swift3_varnish_detected', function($detected) {
    // Force Varnish detection in staging environment
    if (defined('WP_ENVIRONMENT_TYPE') && WP_ENVIRONMENT_TYPE === 'staging') {
        return true;
    }
    return $detected;
});
swift3_varnish_not_detected

When Varnish is enabled, Swift will purge Varnish cache if necessary. If the purge request returns an error, Swift will disable Varnish auto purge by default. This filter allows you to override this behavior and keep Varnish enabled even when purge requests fail.

Parameters:
  • $not_detected (boolean) - Whether Varnish purge failed (true if failed, which would disable Varnish by default)
Default:

Based on HTTP response code (not 200) or missing x-varnish header in response

Example:
// Keep Varnish enabled even when purge requests fail for specific hosts
add_filter('swift3_varnish_not_detected', function($not_detected) {
    // Get the current hostname
    $hostname = $_SERVER['HTTP_HOST'];
    
    // List of hosts where we want to keep Varnish enabled regardless of purge status
    $keep_varnish_hosts = array('staging.example.com', 'dev.example.com');
    
    // If current host is in our list, keep Varnish enabled
    if (in_array($hostname, $keep_varnish_hosts)) {
        return false; // Return false to prevent disabling Varnish
    }
    
    return $not_detected; // Otherwise use default behavior
});
swift3_cloudflare_detected

Filter whether Cloudflare is detected for the site. Swift Performance uses this to determine if Cloudflare-specific optimizations should be applied.

Parameters:
  • $detected (boolean) - Whether Cloudflare is detected
Default:

Based on HTTP_CF_RAY server variable

Example:
// Force Cloudflare detection to be enabled
add_filter('swift3_cloudflare_detected', '__return_true');

// OR

// Force Cloudflare detection to be disabled
add_filter('swift3_cloudflare_detected', '__return_false');
swift3_jet_blog_detected

Filter whether Jet Blog plugin is detected. Swift Performance uses this to apply specific optimizations for Jet Blog plugin.

Parameters:
  • $detected (boolean) - Whether Jet Blog plugin is detected
Default:

Based on whether the Jet Blog plugin is active

Example:
// Force Jet Blog detection to be enabled
add_filter('swift3_jet_blog_detected', '__return_true');

// OR

// Force Jet Blog detection to be disabled
add_filter('swift3_jet_blog_detected', '__return_false');
swift3_excluded_edd_pages

Filter the list of Easy Digital Downloads pages to exclude from caching.

Parameters:
  • $excluded_pages (array) - Array of EDD page IDs to exclude from caching
Default:

Purchase page, success page, failure page, and purchase history page from EDD settings

Example:
// Add additional EDD pages to exclude from caching
add_filter('swift3_excluded_edd_pages', function($excluded_pages) {
    // Add a custom EDD-related page to the exclusion list
    $excluded_pages[] = 123; // Page ID of a custom EDD-related page
    
    return $excluded_pages;
});
swift3_excluded_surecart_pages

Filter the list of SureCart pages to exclude from caching.

Parameters:
  • $excluded_pages (array) - Array of SureCart page IDs to exclude from caching
Default:

Default SureCart checkout and account pages

Example:
// Add additional SureCart pages to exclude from caching
add_filter('swift3_excluded_surecart_pages', function($excluded_pages) {
    // Add a custom SureCart-related page to the exclusion list
    $excluded_pages[] = 456; // Page ID of a custom SureCart-related page
    
    return $excluded_pages;
});
swift3_elementor_widget_settings

Filter Elementor widget settings before processing for fragment caching. This allows you to modify widget settings before they are used to create fragment wrappers.

Parameters:
  • $settings (array) - The Elementor widget settings
  • $widget_content (string) - The widget content
  • $that (object) - The Elementor widget instance
Default:

Original widget settings from $data['settings']

Example:
// Modify Elementor widget settings to force ajaxify for specific widget types
add_filter('swift3_elementor_widget_settings', function($settings, $widget_content, $widget) {
    // Force ajaxify for post widgets
    if ($widget->get_name() === 'posts' || $widget->get_name() === 'archive-posts') {
        $settings['swift-ajaxify'] = 'yes';
    }
    
    return $settings;
}, 10, 3);
swift3_elementor_widget_fragment

Filter whether to create a fragment for an Elementor widget. This allows you to control which widgets should be ajaxified even if they have the 'swift-ajaxify' setting enabled.

Parameters:
  • $create_fragment (boolean) - Whether to create a fragment for the widget (default: true)
  • $that (object) - The Elementor widget instance
Default:

true

Example:
// Prevent specific Elementor widgets from being ajaxified
add_filter('swift3_elementor_widget_fragment', function($create_fragment, $widget) {
    // Don't create fragments for image widgets
    if ($widget->get_name() === 'image') {
        return false;
    }
    
    // Don't create fragments for widgets in specific sections
    $section = $widget->get_parent();
    if ($section && $section->get_id() === 'header-section') {
        return false;
    }
    
    return $create_fragment;
}, 10, 2);
swift3_fragment_callback

Filter the JavaScript callback function that will be executed after a fragment is loaded via AJAX. This allows you to add custom JavaScript functionality to fragments.

Parameters:
  • $callback (string) - The JavaScript callback function (default: empty string)
  • $widget_content (string) - The widget content
  • $that (object) - The Elementor widget instance
Default:

Empty string

Example:
// Initialize Jet Menu after fragment is loaded via AJAX
add_filter('swift3_fragment_callback', function($callback, $content, $that){
    // Check if this is a Jet Menu widget
    if (in_array($that->get_name(), array('jet-mobile-menu', 'jet-mega-menu'))){
        // Return JavaScript to be executed after fragment loads
        // This will initialize Jet Menu if it exists
        $callback = '(typeof jetMenu !== \'undefined\' && jetMenu.init())';
    }

    return $callback;
}, 10, 3);
swift3_should_fragment

Controls whether fragment caching should be enabled globally. This is a master switch for all fragment functionality.

Parameters:
  • $should_fragment (boolean) - Whether fragment caching should be enabled
Default:

true unless swift3_skip_optimizer returns true or nocache query parameter is present

Example:
// Disable fragment caching for specific pages or user roles
add_filter('swift3_should_fragment', function($should_fragment) {
    // Disable fragments for specific page templates
    if (is_page_template('template-no-fragments.php')) {
        return false;
    }
    
    // Disable fragments for editors and administrators
    if (current_user_can('edit_posts')) {
        return false;
    }
    
    // Disable fragments for specific post types
    if (is_singular('product')) {
        return false;
    }
    
    return $should_fragment;
});
swift3_elementor_template_types

Filter the list of Elementor template types and their labels. This is used when displaying template type information in the Swift Performance interface.

Parameters:
  • $labels (array) - Associative array of template type keys and their display labels
Default:

array('wp-post' => 'Post', 'wp-page' => 'Page')

Example:
// Add custom Elementor template types to Swift Performance
add_filter('swift3_elementor_template_types', function($labels) {
    // Add support for Elementor Pro template types
    $labels['section'] = 'Section';
    $labels['header'] = 'Header';
    $labels['footer'] = 'Footer';
    $labels['single'] = 'Single';
    $labels['archive'] = 'Archive';
    $labels['popup'] = 'Popup';
    
    // Add custom template type
    $labels['custom-type'] = 'Custom Template';
    
    return $labels;
});
swift3_elementor_detected

Filter whether Elementor is detected on the site. This allows you to override the automatic detection of Elementor.

Parameters:
  • $detected (boolean) - Whether Elementor is detected (default: based on ELEMENTOR__FILE__ constant)
Default:

true if the ELEMENTOR__FILE__ constant is defined

Example:
// Force Swift Performance to use Elementor optimizations even if Elementor is not detected
add_filter('swift3_elementor_detected', '__return_true');

// OR

// Disable Elementor-specific optimizations even when Elementor is installed
add_filter('swift3_elementor_detected', '__return_false');
swift3_excluded_woocommerce_pages

Modifies the list of WooCommerce pages that should be excluded from caching.

Parameters:
  • $excluded_pages (array) - Array of page IDs to exclude
Default:

Cart, checkout, and account pages

Example:
// Add additional WooCommerce pages to exclude from caching
add_filter('swift3_excluded_woocommerce_pages', function($excluded_pages) {
    // Add the thank you page to excluded pages
    $thank_you_page_id = get_option('woocommerce_thanks_page_id');
    if ($thank_you_page_id) {
        $excluded_pages[] = $thank_you_page_id;
    }
    
    // Also exclude the wishlist page if using YITH WooCommerce Wishlist
    $wishlist_page_id = get_option('yith_wcwl_wishlist_page_id');
    if ($wishlist_page_id) {
        $excluded_pages[] = $wishlist_page_id;
    }
    
    return $excluded_pages;
});
swift3_woocommerce_price_fragment

Filter whether to create a fragment for WooCommerce prices. This controls whether product prices should be loaded via AJAX (as fragments) or included directly in the cached page.

Parameters:
  • $create_fragment (boolean) - Whether to create a fragment for the price (default: true)
  • $product (WC_Product) - The product object
Default:

true

Example:
// Only create price fragments for variable products
add_filter('swift3_woocommerce_price_fragment', function($create_fragment, $product) {
    // Only create fragments for variable products (which may have different prices based on user location)
    if ($product->is_type('variable')) {
        return true;
    }
    
    // For simple products, include the price directly in the cached page
    return false;
}, 10, 2);

// OR

// Disable price fragments for specific product categories
add_filter('swift3_woocommerce_price_fragment', function($create_fragment, $product) {
    // Get product categories
    $terms = get_the_terms($product->get_id(), 'product_cat');
    
    if ($terms && !is_wp_error($terms)) {
        foreach ($terms as $term) {
            // Don't create fragments for products in the 'fixed-price' category
            if ($term->slug === 'fixed-price') {
                return false;
            }
        }
    }
    
    return $create_fragment;
}, 10, 2);
swift3_ajax_update_{option}_option

Filter the result of updating an option via AJAX.

swift3_http_request_cache_expiry

Controls the expiration time (in seconds) for cached HTTP requests.

Parameters:
  • $expiry (integer) - Default expiry time (300 seconds)
  • $url (string) - The URL being requested
  • $args (array) - Request arguments
Example:
// Extend cache expiry for specific API endpoints
add_filter('swift3_http_request_cache_expiry', function($expiry, $url, $args) {
    // Cache weather API requests longer (1 hour)
    if (strpos($url, 'api.weather.com') !== false) {
        return 3600; // 1 hour
    }
    
    // Cache other external APIs for 10 minutes
    if (strpos($url, 'external-domain.com') !== false) {
        return 600; // 10 minutes
    }
    
    // Cache WooCommerce API requests for less time
    if (strpos($url, 'wc-api') !== false) {
        return 60; // 1 minute
    }
    
    return $expiry;
}, 10, 3);
swift3_http_request_cache_response

Filter the cached HTTP response before returning it. This allows you to modify or validate the cached response data.

Parameters:
  • $response (array) - The cached response data
  • $url (string) - The URL being requested
  • $args (array) - Request arguments
Default:

The cached transient value

Example:
// Modify cached API responses to ensure data is fresh
add_filter('swift3_http_request_cache_response', function($response, $url, $args) {
    // For weather API responses, check if the data is too old
    if (strpos($url, 'api.weather.com') !== false) {
        // If the timestamp in the response is more than 1 hour old, return false to force a fresh request
        if (isset($response['body']) && is_string($response['body'])) {
            $data = json_decode($response['body'], true);
            if (isset($data['timestamp']) && ($data['timestamp'] + 3600) < time()) {
                return false; // Force a fresh request
            }
        }
    }
    
    return $response;
}, 10, 3);
swift3_http_request_cache_url

Filter the URL used for HTTP request cache key generation. This allows you to normalize URLs to improve cache hit rates.

Parameters:
  • $url (string) - The URL being requested
  • $args (array) - Request arguments
Default:

The original URL

Example:
// Normalize API URLs to improve cache hit rates
add_filter('swift3_http_request_cache_url', function($url, $args) {
    // For multilingual sites, remove language code from URL to share cache
    if (strpos($url, '/api/') !== false) {
        // Remove language path segments like /en/ or /fr/ from the URL
        $url = preg_replace('#(https?://[^/]+)/([a-z]{2})/#', '$1/', $url);
    }
    
    // Remove tracking parameters that don't affect the response
    if (strpos($url, '?') !== false) {
        $url_parts = parse_url($url);
        if (isset($url_parts['query'])) {
            parse_str($url_parts['query'], $params);
            // Remove tracking parameters
            unset($params['utm_source'], $params['utm_medium'], $params['utm_campaign']);
            // Rebuild URL
            $url_parts['query'] = http_build_query($params);
            $url = Swift3_Helper::build_url($url_parts);
        }
    }
    
    return $url;
}, 10, 2);
swift3_http_request_cache_args

Filter the arguments used for HTTP request cache key generation. This allows you to normalize or remove request arguments that don't affect the response content.

Parameters:
  • $args (array) - Request arguments
  • $url (string) - The URL being requested
Default:

The original request arguments

Example:
// Clean up request arguments to improve cache hit rates
add_filter('swift3_http_request_cache_args', function($args, $url) {
    // Remove non-deterministic headers that don't affect the response
    if (isset($args['headers'])) {
        // Remove request-specific headers
        unset($args['headers']['X-WP-Nonce']);
        unset($args['headers']['X-Requested-With']);
        
        // Remove user-specific headers for shared caching
        unset($args['headers']['Cookie']);
        unset($args['headers']['Authorization']);
    }
    
    // For Query Monitor compatibility, remove its added parameters
    if (class_exists('QM_Dispatchers')) {
        unset($args['_qm_key']);
    }
    
    return $args;
}, 10, 2);
swift3_toolbar_is_page_cacheable

Filter whether a page is cacheable as displayed in the Swift Performance toolbar. This allows you to modify the cacheability status shown in the toolbar without affecting the actual caching behavior.

Parameters:
  • $is_cacheable (boolean) - Whether the current page is cacheable
Default:

Result of Swift3::get_module('cache')->is_page_cacheable()

Example:
// Always show the current page as cacheable in the toolbar for administrators
add_filter('swift3_toolbar_is_page_cacheable', function($is_cacheable) {
    // Only modify the toolbar display for administrators
    if (current_user_can('manage_options')) {
        return true;
    }
    
    return $is_cacheable;
});

// OR

// Show specific pages as non-cacheable in the toolbar for testing purposes
add_filter('swift3_toolbar_is_page_cacheable', function($is_cacheable) {
    // Get current URL
    $current_url = Swift3_Helper::get_current_url();
    
    // Mark specific test pages as non-cacheable in the toolbar
    if (strpos($current_url, '/test-page/') !== false) {
        return false;
    }
    
    return $is_cacheable;
});
swift3_collage_result_{type}

Filter the result of a collage operation by type. The {type} placeholder is replaced with the specific collage type (e.g., 'admin_bar'). This allows you to modify the HTML content returned by different collage operations.

Parameters:
  • $result (string) - The HTML content generated by the collage operation
  • $data (array) - Data passed to the collage operation
Default:

The HTML content generated by the specific collage operation

Example:
// Modify the admin bar collage content
add_filter('swift3_collage_result_admin_bar', function($result, $data) {
    // Remove specific items from the admin bar
    $result = preg_replace('/<li id="wp-admin-bar-updates".*?<\/li>/s', '', $result);
    
    // Add custom notification to the admin bar
    $result = str_replace('</ul></div>', '<li id="custom-notification"><a href="#">Custom Notification</a></li></ul></div>', $result);
    
    return $result;
}, 10, 2);
swift3_collage_admin_bar_request

Filter the admin bar collage request parameters. This allows you to modify the data used to generate the admin bar fragment request.

Parameters:
  • $request (array) - Array containing collage request data: [0] => 'collage', [1] => queried_object_id, [2] => 'admin_bar'
Default:

array('collage', $wp_the_query->queried_object_id, 'admin_bar')

Example:
// Modify the admin bar collage request to include additional data
add_filter('swift3_collage_admin_bar_request', function($request) {
    // Add a custom identifier to the request
    $request[3] = 'custom_admin_bar';
    
    // Add user role information to the request
    if (is_user_logged_in()) {
        $user = wp_get_current_user();
        $request[4] = $user->roles[0];
    }
    
    return $request;
});
swift3_admin_cache_notices

Filter the HTML content of admin notices before they are cached. This allows you to modify, remove, or add notices in the WordPress admin area when using Swift Performance's admin cache.

Parameters:
  • $notices (string) - The HTML content of admin notices
Default:

The output buffer content from the admin_notices hook

Example:
// Remove specific admin notices from the cache
add_filter('swift3_admin_cache_notices', function($notices) {
    // Remove update notifications
    $notices = preg_replace('/<div class="update-nag".*?<\/div>/s', '', $notices);
    
    // Remove specific plugin notices
    $notices = preg_replace('/<div class="notice" id="woocommerce-message".*?<\/div>/s', '', $notices);
    
    // Add a custom notice
    $custom_notice = '<div class="notice notice-info"><p>This is a custom cached notice.</p></div>';
    $notices .= $custom_notice;
    
    return $notices;
});
swift3_admin_cache_menu

Filter the WordPress admin menu array before it is cached. This allows you to modify the admin menu structure when using Swift Performance's admin cache.

Parameters:
  • $menu (array) - The global WordPress admin menu array
Default:

The global $menu array

Example:
// Modify the admin menu before it's cached
add_filter('swift3_admin_cache_menu', function($menu) {
    // Remove specific menu items
    foreach ($menu as $key => $item) {
        // Remove the Comments menu item
        if (isset($item[2]) && $item[2] === 'edit-comments.php') {
            unset($menu[$key]);
        }
        
        // Remove the Tools menu item
        if (isset($item[2]) && $item[2] === 'tools.php') {
            unset($menu[$key]);
        }
    }
    
    // Add a custom menu item
    $menu[] = array(
        0 => 'Custom Menu',
        1 => 'read',
        2 => 'custom-menu',
        3 => '',
        4 => 'menu-top',
        5 => 'custom-menu-top',
        6 => 'dashicons-admin-generic'
    );
    
    return $menu;
});
swift3_code_optimizer

Determines whether code optimization should be enabled for the current request.

Parameters:
  • $enabled (boolean) - Whether optimization is enabled
Default:

true

Example:
// Disable code optimization for specific post types
add_filter('swift3_code_optimizer', function($enabled) {
    global $post;
    
    // Disable for landing pages
    if (isset($post) && $post->post_type === 'landing_page') {
        return false;
    }
    
    // Disable for pages with specific template
    if (is_page_template('template-fullwidth.php')) {
        return false;
    }
    
    // Disable for specific page IDs
    if (is_page(array(123, 456, 789))) {
        return false;
    }
    
    return $enabled;
});
swift3_skip_optimizer

Controls whether optimization should be skipped for the current request. This is a master switch that affects all optimization features including caching, CSS/JS optimization, and fragments.

Parameters:
  • $skip (boolean) - Whether to skip optimization (default: false)
Default:

false, but automatically returns true if ?preview, ?nocache, or ?swift-test-page query parameters are present

Example:
// Skip optimization for specific user agents or conditions
add_filter('swift3_skip_optimizer', function($skip) {
    // Skip optimization for page builders
    if (isset($_GET['elementor-preview']) || isset($_GET['et_fb']) || isset($_GET['fl_builder'])) {
        return true;
    }
    
    // Skip optimization for specific user roles
    if (current_user_can('editor') || current_user_can('shop_manager')) {
        return true;
    }
    
    // Skip optimization for specific page templates
    if (is_page_template('template-custom.php')) {
        return true;
    }
    
    // Skip optimization based on custom cookie
    if (isset($_COOKIE['disable_optimization'])) {
        return true;
    }
    
    return $skip;
});
swift3_cache_device

Controls the suffix added to cache files to differentiate between device types.

Parameters:
  • $suffix (string) - The device suffix, default is '-mobile' for mobile devices when SWIFT3_SEPARATE_DEVICES is defined
Example:
// Create separate cache files for tablets
add_filter('swift3_cache_device', function($suffix) {
    // Check if it's a tablet using a detection function
    if (function_exists('wp_is_tablet') && wp_is_tablet()) {
        return '-tablet';
    }
    
    // Otherwise return the default suffix
    return $suffix;
});
swift3_gutenberg_block_fragment

Filter whether to create a fragment for a Gutenberg block. This allows you to control which blocks should be loaded via AJAX as fragments.

Parameters:
  • $create_fragment (boolean) - Whether to create a fragment for the block (default: true)
  • $block (array) - The block data array
Default:

true for blocks with the isSwiftPerfrormanceLazyloaded attribute set to true

Example:
// Prevent specific Gutenberg blocks from being ajaxified
add_filter('swift3_gutenberg_block_fragment', function($create_fragment, $block) {
    // Don't create fragments for specific block types
    if (isset($block['blockName'])) {
        // Don't create fragments for image blocks
        if ($block['blockName'] === 'core/image') {
            return false;
        }
        
        // Don't create fragments for blocks in the 'acf' namespace
        if (strpos($block['blockName'], 'acf/') === 0) {
            return false;
        }
    }
    
    // Don't create fragments for blocks with specific attributes
    if (isset($block['attrs']['data-no-fragment']) && $block['attrs']['data-no-fragment']) {
        return false;
    }
    
    return $create_fragment;
}, 10, 2);
swift3_shortcode_fragment

Filter whether to create a fragment for a shortcode. This allows you to control which shortcodes should be loaded via AJAX as fragments, even if they are in the shortcode fragments list.

Parameters:
  • $create_fragment (boolean) - Whether to create a fragment for the shortcode (default: true)
  • $shortcode (string) - The shortcode tag
  • $atts (array) - The shortcode attributes
Default:

true for shortcodes listed in the shortcode fragments setting

Example:
// Conditionally prevent specific shortcodes from being ajaxified
add_filter('swift3_shortcode_fragment', function($create_fragment, $shortcode, $atts) {
    // Don't create fragments for the contact form shortcode on the contact page
    if ($shortcode === 'contact-form-7' && is_page('contact')) {
        return false;
    }
    
    // Don't create fragments for gallery shortcodes with specific IDs
    if ($shortcode === 'gallery' && isset($atts['id'])) {
        $excluded_gallery_ids = array(123, 456, 789);
        if (in_array($atts['id'], $excluded_gallery_ids)) {
            return false;
        }
    }
    
    // Don't create fragments for any shortcodes in the sidebar
    global $wp_current_filter;
    if (in_array('dynamic_sidebar_before', $wp_current_filter) || in_array('dynamic_sidebar_after', $wp_current_filter)) {
        return false;
    }
    
    return $create_fragment;
}, 10, 3);
swift3_option_{key}

Filter the value of any Swift Performance option when it's retrieved. Replace {key} with the actual option name (e.g., swift3_option_caching).

This is a powerful hook that allows you to dynamically modify any option value at runtime without changing the stored value in the database.

Parameters:
  • $value (mixed) - The current option value
Example:
// Force caching off in development environment
add_filter('swift3_option_caching', function($value) {
    if (defined('WP_DEBUG') && WP_DEBUG) {
        return ''; // Disable caching
    }
    return $value;
});

// Dynamically adjust cache lifespan based on post type
add_filter('swift3_option_cache-lifespan', function($value) {
    if (is_singular('product')) {
        return 3600; // 1 hour for products
    }
    return $value;
});
swift3_option_not_set_{key}

Filter the default value returned when an option is not set in the database.

Parameters:
  • $default (mixed) - The default value
Example:
// Provide a custom default for an option
add_filter('swift3_option_not_set_custom-setting', function($default) {
    return 'my_default_value';
});
swift3_update_option_{key}

Filter the value before an option is updated in the database.

Parameters:
  • $value (mixed) - The value about to be saved
Example:
// Sanitize value before saving
add_filter('swift3_update_option_custom-url', function($value) {
    return esc_url_raw($value);
});
swift3_check_option_{key}

Filter the result of checking an option value with a comparison operator.

Parameters:
  • $result (boolean) - The comparison result
  • $value (mixed) - The value being compared
  • $compare (string) - The comparison operator (=, !=, <, >, <=, >=, CONTAINS, IN)
swift3_get_template

Filter template content before it's returned. Useful for modifying JavaScript or PHP templates used by the plugin.

Parameters:
  • $content (string) - The template content
  • $template (string) - The template name
  • $type (string) - The template type ('tpl' or 'js')
swift3_ua_string

Filter the User Agent string used for HTTP requests made by Swift Performance.

Parameters:
  • $ua_string (string) - The User Agent string
  • $context (string) - The context ('default', 'cache-hit', 'litespeed-purge-request', etc.)
Default:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Swift Performance

Example:
// Customize User Agent for cache warming requests
add_filter('swift3_ua_string', function($ua_string, $context) {
    if ($context === 'cache-hit') {
        return 'Swift Performance Cache Warmer/1.0';
    }
    return $ua_string;
}, 10, 2);
swift3_cache_buffer

Filter the page buffer before caching decisions are made. This allows you to modify the content before Swift Performance analyzes it.

Parameters:
  • $buffer (string) - The page HTML content
Example:
// Add custom markers to the HTML before caching
add_filter('swift3_cache_buffer', function($buffer) {
    return str_replace('', '', $buffer);
});
swift3_is_request_cacheable

Filter whether the current HTTP request is cacheable. This check happens before content generation.

Return false to prevent caching for specific request conditions like special query parameters, request methods, or custom headers.

Parameters:
  • $cacheable (boolean) - Whether the request is cacheable
Example:
// Don't cache requests from specific IP addresses
add_filter('swift3_is_request_cacheable', function($cacheable) {
    $blocked_ips = array('192.168.1.100', '10.0.0.50');
    if (in_array($_SERVER['REMOTE_ADDR'], $blocked_ips)) {
        return false;
    }
    return $cacheable;
});

// Don't cache requests with specific headers
add_filter('swift3_is_request_cacheable', function($cacheable) {
    if (isset($_SERVER['HTTP_X_NO_CACHE'])) {
        return false;
    }
    return $cacheable;
});
swift3_is_page_cacheable

Filter whether the current page content is cacheable. This check happens after content generation.

Parameters:
  • $cacheable (boolean) - Whether the page is cacheable
Example:
// Don't cache pages with specific content
add_filter('swift3_is_page_cacheable', function($cacheable) {
    global $post;
    if (isset($post->post_content) && strpos($post->post_content, '[private-content]') !== false) {
        return false;
    }
    return $cacheable;
});
swift3_skippable

Filter whether caching should be completely skipped for the current request (e.g., for logged-in users, POST requests, etc.).

This is checked very early in the request lifecycle, even before output buffering starts.

Parameters:
  • $skippable (boolean) - Whether caching should be skipped
Example:
// Skip caching for premium members
add_filter('swift3_skippable', function($skippable) {
    if (is_user_logged_in()) {
        $user = wp_get_current_user();
        if (in_array('premium_member', $user->roles)) {
            return true; // Skip cache for premium members
        }
    }
    return $skippable;
});
swift3_checksum_source

Filter the page source before generating the checksum. The checksum is used to detect if page content has changed and needs re-optimization.

This is extremely useful for removing dynamic content that doesn't affect optimization (like nonces, timestamps, session tokens) so they don't trigger unnecessary re-optimization.

Parameters:
  • $code (string) - The page source code
Example:
// Remove custom dynamic elements before checksum
add_filter('swift3_checksum_source', function($code) {
    // Remove session tokens
    $code = preg_replace('~data-session="[^"]*"~', '', $code);
    
    // Remove custom timestamps
    $code = preg_replace('~data-timestamp="[^"]*"~', '', $code);
    
    // Remove CSRF tokens
    $code = preg_replace('~data-csrf="[^"]*"~', '', $code);
    
    return $code;
});
swift3_cache_basedir

Filter the base directory where cache files are stored.

Parameters:
  • $basedir (string) - The cache directory path
Default:

WP_CONTENT_DIR . '/swift-ai/cache/'

Example:
// Store cache in a custom location
add_filter('swift3_cache_basedir', function($basedir) {
    return '/custom/cache/path/';
});
swift3_miss_header

Filter the HTTP header sent when a page is NOT served from cache (cache miss).

Parameters:
  • $header (string) - The header string
Default:

'Swift3: MISS'

swift3_cache_header

Filter the HTTP header sent when a page IS served from cache (cache hit).

Parameters:
  • $header (string) - The header string
Default:

'Swift3: HIT/PHP' (or 'Swift3: HIT/Proxy' when using proxy cache)

swift3_cache_function

Filter the function used to save cache files. This allows you to implement custom cache storage backends.

Parameters:
  • $callback (callable) - The cache function callback
Example:
// Use custom cache storage (e.g., Redis, Memcached)
add_filter('swift3_cache_function', function() {
    return array('My_Custom_Cache_Class', 'save_cache');
});
swift3_get_current_url

Filter the detected current URL before it's used for caching or warmup.

Parameters:
  • $url (string) - The current URL
swift3_excluded_urls

Filter the array of URLs that are automatically excluded from caching.

Parameters:
  • $urls (array) - Array of excluded URLs with ID as key
swift3_excluded_post_types

Filter the array of post types that are excluded from caching.

Parameters:
  • $post_types (array) - Array of post type names
Example:
// Exclude custom post types from caching
add_filter('swift3_excluded_post_types', function($post_types) {
    $post_types[] = 'my_custom_cpt';
    $post_types[] = 'private_content';
    return $post_types;
});
swift3_default_allowed_query_parameters

Filter the default allowed query parameters that can create separate cache variations.

Parameters:
  • $parameters (array) - Array of query parameter names
Default:

array('p', 'page_id')

swift3_default_ignored_query_strings

Filter the default ignored query parameters (typically tracking parameters that don't affect page content).

Parameters:
  • $parameters (array) - Array of query parameter names to ignore
Default:

Includes utm_*, fbclid, gclid, _ga, and other common tracking parameters

Example:
// Add custom tracking parameters to ignore list
add_filter('swift3_default_ignored_query_strings', function($parameters) {
    $parameters[] = 'custom_ref';
    $parameters[] = 'campaign_id';
    $parameters[] = 'partner';
    return $parameters;
});
swift3_skip_optimizer

Filter whether to skip the optimizer entirely for the current request. When true, no CSS/JS/Image optimization will be performed.

Parameters:
  • $skip (boolean) - Whether to skip optimization
Example:
// Skip optimization for AMP pages
add_filter('swift3_skip_optimizer', function($skip) {
    $current_url = Swift3_Helper::get_current_url();
    if (strpos($current_url, '/amp/') !== false) {
        return true;
    }
    return $skip;
});

// Skip optimization for print pages
add_filter('swift3_skip_optimizer', function($skip) {
    if (isset($_GET['print'])) {
        return true;
    }
    return $skip;
});
swift3_image_handler_img_tag

Filter an individual image tag object before processing. This gives you fine-grained control over how each image is optimized.

The tag parameter is a Swift3_HTML_Tag object with properties like attributes, inner_html, and outer_html.

Parameters:
  • $tag (Swift3_HTML_Tag) - The image tag object
Example:
// Force high priority for hero images
add_filter('swift3_image_handler_img_tag', function($tag) {
    if (isset($tag->attributes['class']) && 
        strpos($tag->attributes['class'], 'hero-image') !== false) {
        // Remove lazy loading
        unset($tag->attributes['loading']);
        // Set high fetch priority
        $tag->attributes['fetchpriority'] = 'high';
    }
    return $tag;
});

// Add custom data attributes for tracking
add_filter('swift3_image_handler_img_tag', function($tag) {
    if (isset($tag->attributes['src'])) {
        $tag->attributes['data-original-src'] = $tag->attributes['src'];
    }
    return $tag;
});
swift3_skip_image

Filter whether a specific image should be skipped from optimization (including WebP conversion and responsive images).

Parameters:
  • $skip (boolean) - Whether to skip the image
  • $image_url (string) - The image URL
Example:
// Skip images from external CDN
add_filter('swift3_skip_image', function($skip, $image_url) {
    if (strpos($image_url, 'cdn.example.com') !== false) {
        return true;
    }
    return $skip;
}, 10, 2);

// Skip SVG images
add_filter('swift3_skip_image', function($skip, $image_url) {
    if (preg_match('~\.svg~i', $image_url)) {
        return true;
    }
    return $skip;
}, 10, 2);
swift3_is_priority_1 through swift3_is_priority_6

Filter whether the current page matches a specific priority level for cache warmup. Lower numbers = higher priority.

Priority Levels:

  • Priority 1: Homepage/Front page (highest priority)
  • Priority 2: Pages
  • Priority 3: Categories
  • Priority 4: Archives
  • Priority 5: Single posts
  • Priority 6: Low priority pages
Parameters:
  • $is_priority (boolean) - Whether the page matches this priority
Example:
// Set custom post type to priority 2
add_filter('swift3_is_priority_2', function($is_priority) {
    if (is_singular('portfolio')) {
        return true;
    }
    return $is_priority;
});

// Give shop page priority 1
add_filter('swift3_is_priority_1', function($is_priority) {
    if (function_exists('is_shop') && is_shop()) {
        return true;
    }
    return $is_priority;
});
swift3_prefetch_ignore

Filter query parameters that should be ignored for link prefetching.

Parameters:
  • $list (array) - Array of query parameter names
Example:
// Don't prefetch links with custom actions
add_filter('swift3_prefetch_ignore', function($list) {
    $list[] = 'download';
    $list[] = 'action';
    $list[] = 'export';
    return $list;
});
swift3_should_fragment

Filter whether the fragment system should be active for the current request.

Parameters:
  • $should_fragment (boolean) - Whether fragments should be used
swift3_css_layer

Filter the CSS @layer name used for Swift Performance styles.

Parameters:
  • $layer (string) - The layer name
Default:

'swift3'

Action hooks allow you to execute custom code at specific points in Swift Performance's execution. Here's a complete list of action hooks available in Swift Performance AI. You can use these hooks in your theme's functions.php file or in a custom plugin.

Note: Action hooks should be added using the add_action() WordPress function. The general syntax is:

add_action('hook_name', 'callback_function', priority, accepted_args);
where priority is optional (default: 10) and accepted_args is optional (default: 1).

swift3_option_{key}_updated

Triggered when a specific Swift Performance option is updated. Replace {key} with the actual option name.

Parameters:
  • $value - The new value for the option
swift3_option_updated

Triggered when any option is updated.

Parameters:
  • $key (string) - The option key that was updated
  • $value (mixed) - The new value for the option
swift3_collage_before_{type}

Triggered before a collage operation of a specific type. The {type} placeholder is replaced with the specific collage type (e.g., 'admin_bar').

Parameters:
  • $data (array) - Data passed to the collage operation
swift3_before_collage_admin_bar_assets

Triggered before loading admin bar assets in collage.

swift3_cache_done

Fired when a URL has been successfully cached.

Parameters:
  • $url (string) - The URL that was cached
swift3_transient_status

Triggered when a transient status changes.

Parameters:
  • $old_status (integer) - The previous status code
  • $new_status (integer) - The new status code
  • $url (string) - The URL associated with the status change
swift3_warmup_post_types

Filter the post types that should be included in the cache warmup process. This allows you to add or remove post types from the warmup queue.

Parameters:
  • $post_types (array) - Array of post type names to include in warmup
Default:

All public and publicly queryable post types, excluding those in the exclusion settings

swift3_warmup_add_url

Triggered when a URL is added to the cache warmup queue.

Parameters:
  • $url (string) - The URL being added to the warmup queue
  • $priority (integer) - The priority of the URL in the queue
  • $post_id (integer|null) - The post ID associated with the URL, if available
swift3_get_install_steps

Triggered when getting installation steps.

swift_after_header

Triggered after the header is processed by the optimizer.

swift3_code_optimizer_before_check_plugin

Triggered before checking a plugin in the code optimizer.

swift3_page_discovered

Triggered when a new page is discovered during normal browsing (not prebuild). This allows you to track which pages are being accessed and added to the warmup queue.

Parameters:
  • $url (string) - The discovered URL
  • $priority (integer) - The assigned priority level (1-6)
Example:
// Log discovered pages
add_action('swift3_page_discovered', function($url, $priority) {
    error_log("Swift Performance discovered: $url (Priority: $priority)");
}, 10, 2);

// Adjust priority for specific URL patterns
add_action('swift3_page_discovered', function($url, $priority) {
    if (strpos($url, '/special/') !== false) {
        Swift3_Warmup::update_url($url, array('priority' => 1));
    }
}, 10, 2);
swift3_invalidate_cache

Triggered when cache is invalidated for a URL or globally.

Parameters:
  • $url (string) - The URL being invalidated (empty for global invalidation)
  • $object (mixed) - The object that triggered the invalidation
  • $action (string) - The action that triggered invalidation (e.g., 'save_post', 'delete_post')
Example:
// Log cache invalidations
add_action('swift3_invalidate_cache', function($url, $object, $action) {
    if (empty($url)) {
        error_log("Swift Performance: Global cache invalidation triggered by: $action");
    } else {
        error_log("Swift Performance: Cache invalidated for $url (action: $action)");
    }
}, 10, 3);
swift3_invalidate_object

Triggered when cache is invalidated for a specific URL or all URLs.

Parameters:
  • $url (string) - The URL being invalidated (empty for all URLs)
swift3_purge_cache

Triggered when cache is purged (completely deleted) for a URL or globally. This also triggers purging in integrated systems like Cloudflare, Varnish, and LiteSpeed.

Parameters:
  • $url (string) - The URL being purged (empty for global purge)
  • $remove_warmup (boolean) - Whether to remove the URL from warmup queue
Example:
// Trigger external cache purge
add_action('swift3_purge_cache', function($url, $remove_warmup) {
    if (empty($url)) {
        // Purge external CDN cache globally
        my_custom_cdn_purge_all();
    } else {
        // Purge specific URL from external CDN
        my_custom_cdn_purge_url($url);
    }
}, 10, 2);
swift3_development_mode_activated

Triggered when development mode is activated. Development mode typically disables caching and optimization for easier debugging.

Example:
// Notify when development mode is activated
add_action('swift3_development_mode_activated', function() {
    // Send notification to developers
    wp_mail('[email protected]', 'Dev Mode Activated', 'Swift Performance development mode is now active.');
});
swift3_development_mode_deactivated

Triggered when development mode is deactivated.

swift3_generate_rewrites_{server}

Triggered when generating rewrite rules for a specific server type. Replace {server} with the server name (e.g., 'apache', 'nginx', 'litespeed').

Available hooks:

  • swift3_generate_rewrites_apache
  • swift3_generate_rewrites_nginx
  • swift3_generate_rewrites_litespeed
swift3_remove_rewrites_{server}

Triggered when removing rewrite rules for a specific server type during plugin deactivation.

swift3_litespeed_cache_headers

Triggered when LiteSpeed cache headers are being set. Useful for adding custom LiteSpeed-specific headers.

Example:
// Add custom LiteSpeed cache control
add_action('swift3_litespeed_cache_headers', function() {
    header('X-LiteSpeed-Vary: cookie=custom_cookie');
});
swift3_before_shortcode_fragment_callback

Triggered before a shortcode fragment callback is executed. Useful for setting up the environment before fragment rendering.

Parameters:
  • $data (array) - The fragment data array
swift3_rest_action_{path}

Triggered for specific REST API endpoints. Replace {path} with the endpoint path.

Common endpoints:

  • swift3_rest_action_fragments - Fragment loading endpoint
  • swift3_rest_action_litespeed/purge - LiteSpeed cache purge endpoint
swift3_rest_action_{path}

Triggered for a specific REST API path.

swift3_before_shortcode_fragment_callback

Triggered before a shortcode fragment callback.

swift3_config_api_test_error

Triggered when an API test encounters an error.

swift3_config_api_test

Triggered when an API test is performed.

swift3_generate_rewrites_{server}

Triggered when generating rewrites for a specific server type.

swift3_remove_rewrites_{server}

Triggered when removing rewrites for a specific server type.

swift3_development_mode_deactivated

Triggered when development mode is deactivated.

swift3_development_mode_activated

Fired when development mode is activated.

swift3_htaccess_compression

Triggered when generating htaccess compression rules.

swift3_nginx_compression

Triggered when generating Nginx compression rules.

swift3_nginx_browser-cache

Triggered when generating Nginx browser cache rules.

swift3_page_discovered

Triggered when a new page is discovered.

swift3_invalidate_cache

Triggered when cache is invalidated for a URL.

swift3_invalidate_object

Triggered when an object's cache is invalidated.

swift3_purge_cache

Triggered when cache is purged for a specific URL.

Parameters:
  • $url (string) - The URL for which cache is being purged
  • $remove_warmup (boolean) - Whether to remove the URL from warmup queue
swift3_litespeed_cache_headers

Triggered when setting LiteSpeed cache headers.

Constants

Swift Performance AI uses various constants to control its behavior. You can define these constants in your wp-config.php file to override the default values. All constants use the SWIFT3_ prefix.

Note: To define a constant, add it to your wp-config.php file before the line that says "That's all, stop editing! Happy publishing."

SWIFT3_LIMITED_RESOURCES

Shorthand for limited resources mode. When defined, it automatically enables SWIFT3_DISABLE_LOCAL_WEBP and increases SWIFT3_PREBUILD_INTERMISSION to 2,500,000 microseconds (2.5 seconds).

This is useful for shared hosting environments or servers with limited CPU/memory resources.

Default:

Not defined by default

Example:
// Add to wp-config.php for shared hosting environments
define('SWIFT3_LIMITED_RESOURCES', true);
SWIFT3_DISABLE_LOCAL_WEBP

When defined as true, disables the local generation of WebP images. This can be useful on servers with limited resources or where image processing is problematic.

Default:

false

Example:
// Disable WebP conversion on the server
define('SWIFT3_DISABLE_LOCAL_WEBP', true);
SWIFT3_PPTO

API timeout in seconds. This controls how long the plugin will wait for API poll responses. If your server has connectivity issues, increasing this value can help with API reliability.

Default:

600 (10 minutes)

Example:
// Increase API timeout to 15 minutes for slow connections
define('SWIFT3_PPTO', 900);
SWIFT3_WARMUP_POST_TYPE_LIMIT

Sets the maximum number of URLs per post type that will be added to the initial warmup table. For sites with many posts, increasing this value ensures more content is cached.

Default:

1000

Example:
// Increase limit for sites with many posts
define('SWIFT3_WARMUP_POST_TYPE_LIMIT', 2000);
SWIFT3_WARMUP_LIMIT

Sets the maximum total number of URLs that will be added to the initial warmup table. This is a global limit across all post types.

For large sites with many pages, you might want to increase this value to ensure comprehensive caching.

Default:

5000

Example:
// Increase global warmup limit for large sites
define('SWIFT3_WARMUP_LIMIT', 10000);
SWIFT3_MAX_URL_LENGTH

Defines the maximum length of URLs that Swift Performance will cache. URLs exceeding this length will be excluded from caching.

This is particularly useful for sites with complex URL structures or extensive query parameters. Increasing this value allows caching of longer URLs, but may increase disk usage.

Default:

255

Example:
// Increase max URL length for complex URLs with many parameters
define('SWIFT3_MAX_URL_LENGTH', 500);
SWIFT3_CACHE_LIFESPAN

Sets the default cache lifespan in seconds. After this period, cached pages will be automatically regenerated.

For sites with frequently changing content, a shorter lifespan may be appropriate. For more static sites, a longer lifespan can reduce server load.

Default:

43200 (12 hours)

Example:
// Set cache lifespan to 1 day
define('SWIFT3_CACHE_LIFESPAN', 86400);
SWIFT3_PREBUILD_INTERMISSION

Sets the pause time in microseconds between prebuild requests. This helps prevent server overload during cache warming.

For shared hosting or limited resource environments, increasing this value reduces server load but slows down the prebuild process.

Default:

500000 (0.5 seconds)

Example:
// Increase pause time for shared hosting
define('SWIFT3_PREBUILD_INTERMISSION', 1000000);
SWIFT3_WEBP_QUALITY

Sets the quality level for WebP image conversion. Values range from 0 (worst quality, smallest file size) to 100 (best quality, largest file size).

The default value of 83 provides a good balance between quality and file size. Adjust based on your specific needs.

Default:

83

Example:
// Increase WebP quality for photography sites
define('SWIFT3_WEBP_QUALITY', 90);

// Decrease WebP quality to prioritize smaller file sizes
// define('SWIFT3_WEBP_QUALITY', 75);
SWIFT3_DISABLE_LSCACHE

When defined as true, disables LiteSpeed Cache integration. This is useful if you're experiencing conflicts with LiteSpeed Cache.

Default:

false

Example:
// Disable LiteSpeed Cache integration
define('SWIFT3_DISABLE_LSCACHE', true);
DOING_FRAGMENTS

This is an internal constant that indicates Swift Performance is currently processing fragments. It's primarily used by the plugin itself.

Developers can check for this constant in their code to modify behavior when fragments are being processed.

Default:

Not defined by default

Example:
// Check if Swift Performance is processing fragments
if (!defined('DOING_FRAGMENTS')) {
    // Code that should not run during fragment processing
}
DISABLE_SYMLINK

When defined, prevents Swift Performance from using symbolic links for optimized images.

This is useful on hosting environments where symlinks are not supported or restricted. When disabled, the plugin will use direct file copies instead.

Default:

Not defined by default

Example:
// Disable symbolic links for image optimization
define('DISABLE_SYMLINK', true);
DOING_ADMIN_CACHE

An internal constant that indicates Swift Performance is currently processing the WordPress admin area cache.

Like DOING_FRAGMENTS, this is primarily used by the plugin itself, but developers can check for it to modify behavior during admin cache processing.

Default:

Not defined by default

Example:
// Check if Swift Performance is processing admin cache
if (!defined('DOING_ADMIN_CACHE')) {
    // Normal admin processing code
}
DISABLE_TIMEOUT

When defined, prevents Swift Performance from extending PHP execution time limits for long-running processes.

By default, Swift Performance tries to extend timeouts for operations like cache warmup. This constant is useful on hosts where modifying the timeout is not allowed or causes issues.

Default:

Not defined by default

Example:
// Prevent Swift Performance from modifying PHP timeout
define('DISABLE_TIMEOUT', true);
DISABLE_TOOLBAR

When defined, completely disables the Swift Performance toolbar that appears at the bottom of the page for administrators.

This is useful in development environments where the toolbar might interfere with other tools, or if you simply prefer not to see it.

Default:

Not defined by default

Example:
// Disable the Swift Performance toolbar
define('DISABLE_TOOLBAR', true);
INVALIDATE_CACHE_ON_COMMENT

When defined, forces Swift Performance to invalidate the cache for a post when a new comment is submitted.

By default, Swift Performance does not invalidate cache on comments to prevent cache thrashing on popular posts. Enable this if comment display is critical for your site.

Default:

Not defined by default

Example:
// Force cache invalidation when comments are posted
define('INVALIDATE_CACHE_ON_COMMENT', true);
SWIFT3_SLUG

Defines the plugin slug used for internal identification. This is primarily for advanced customization and multi-instance setups.

Default:

'swift3'

Example:
// Use a custom plugin slug (advanced usage only)
define('SWIFT3_SLUG', 'custom_swift');
SWIFT3_IMAGE_INTERMISSION

Wait time in microseconds between image optimizations during prebuild process. This helps prevent server overload when optimizing many images.

Default:

100000 (0.1 seconds)

Example:
// Increase delay for resource-constrained servers
define('SWIFT3_IMAGE_INTERMISSION', 200000); // 0.2 seconds
SWIFT3_HTTP_REQUEST_CACHE_MAX_SIZE

Maximum size of cached HTTP responses in bytes. Used for caching API responses and external HTTP requests made by the plugin.

Default:

1024 bytes (1 KB)

Example:
// Increase cache size for larger API responses
define('SWIFT3_HTTP_REQUEST_CACHE_MAX_SIZE', 4096); // 4 KB
SWIFT3_API_URL

The URL for the Swift Performance API endpoint. This should only be changed if you're using a custom API server.

Default:

'https://api.swiftperformance.io/'

Example:
// Use custom API server (advanced usage)
define('SWIFT3_API_URL', 'https://custom-api.example.com/');
SWIFT3_VARNISH_HOST

The Varnish host URL for purge requests. Used when Varnish is enabled to send cache invalidation requests.

Default:

'http://127.0.0.1'

Example:
// Use custom Varnish host
define('SWIFT3_VARNISH_HOST', 'http://varnish.local:6081');
SWIFT3_SEPARATE_DEVICES

When defined, creates separate cache files for mobile and desktop devices. This is useful when your site shows significantly different content on mobile vs desktop.

Note: Enabling this will increase cache storage requirements and warmup time.

Default:

Not defined (disabled)

Example:
// Enable separate device caching
define('SWIFT3_SEPARATE_DEVICES', true);
SWIFT3_DOING_FRAGMENTS

Internal constant set by Swift Performance when processing fragments. You can check for this constant in your code to determine if fragments are being processed.

This is automatically set during fragment operations and should not be manually defined.

Example:
// Check if fragments are being processed
if (defined('SWIFT3_DOING_FRAGMENTS') && SWIFT3_DOING_FRAGMENTS) {
    // Code specific to fragment processing
    // Example: Skip certain scripts during fragment rendering
    return;
}
SWIFT3_FILE, SWIFT3_DIR, SWIFT3_URL

Internal constants automatically defined by the plugin:

  • SWIFT3_FILE - The main plugin file path
  • SWIFT3_DIR - The plugin directory path (with trailing slash)
  • SWIFT3_URL - The plugin URL (with trailing slash)

These are set automatically and should not be manually defined. They're useful for accessing plugin resources in extensions or custom code.

Example:
// Include a custom file from the plugin directory
require_once SWIFT3_DIR . 'custom/my-extension.php';

// Enqueue a custom script from the plugin directory
wp_enqueue_script('my-script', SWIFT3_URL . 'custom/script.js');

Changelog

1.0.2 – 2025.09.17.

  • [FIX] Minor bugfixes

1.0.1 – 2025.08.13.

  • [FIX] Minor bugfixes

1.0 – 2025.08.05.

  • [IMPROVE] Refactor Critical CSS generation
  • [IMPROVE] Add “Swift Performance” to prebuild user agent string
  • [FIX] Remove invalid lazyload attribute from SSR block requests to prevent REST API errors

0.6.4 – 2025.07.16.

  • [FIX] Minor Bugfixes
  • [FIX] WPBakery compatibility fix

0.6.3.2 – 2025.05.06.

  • [FIX] Minor Bugfixes
  • [IMPROVE] Improved handling of Cloudflare proxy cache purging.
  • [IMPROVE] Minor prebuild improvements.

0.6.2 – 2025.03.18.

  • [FIX] Minor Bugfixes
  • [FIX] Surecart compatibility fix
  • [IMPROVE] WordPress 6.8 compatibility

0.6.1 – 2024.11.30.

  • [FIX] Minor Bugfixes

0.6 – 2024.11.06.

  • [IMPROVE] Must-Have Plugins license management added
  • [FIX] Minor Bugfixes

0.5.13.7 – 2024.10.10.

  • [FIX] Critical CSS loading bug

0.5.13.6 – 2024.10.09.

  • [FIX] Minor bugfixes

0.5.13.5 – 2024.09.04.

  • [FIX] Minor bugfixes
  • [FIX] Cloudflare page rule creation issue

0.5.13.4 – 2024.08.14.

  • [FIX] Fix REST route conflict with WPML (thank you for Alexandre Englebert)
  • [FIX] Cache Management issue
  • [FIX] Compilanz compatibility fix
  • [FIX] Minor bugfixes

0.5.13.3 – 2024.08.08.

  • [FIX] Minor bugfixes
  • [IMPROVE] Fragments compatibility with Astra infinite loader

0.5.13.2 – 2024.07.26.

  • [FIX] Minor bugfixes
  • [IMPROVE] Prefetch links

0.5.13.1 – 2024.07.03.

  • [IMPROVE] JS Engine
  • [IMPROVE] Image Optimizer base64 encoded image handling
  • [FIX] Minor bugfixes

0.5.13 – 2024.06.27.

  • [FIX] Minor bugfixes

0.5.12 – 2024.06.25.

  • [FIX] Minor bugfixes
  • [IMPROVE] Improve JS Engine

0.5.11 – 2024.06.20.

  • [FIX] Minor bugfixes

0.5.10 – 2024.06.04.

  • [FIX] Various minor bugfixes
  • [FIX] Iframe optimizer bug

0.5.9.1 – 2024.04.16.

  • [FIX] Minor bugfixes
  • [FIX] HTML parser

0.5.9 – 2024.04.11.

  • [FIX] Minor bugfixes
  • [IMPROVE] JS Engine

0.5.8.24 – 2024.03.26.

  • [FIX] Minor bugfixes
  • [FIX] Affiliate WP compatibility
  • [IMPROVE] Critical CSS handling

0.5.8.23 – 2024.02.29.

  • [FIX] Minor bugfixes

0.5.8.22 – 2024.02.24.

  • [FIX] Minor bugfixes

0.5.8.21 – 2024.02.15.

  • [FIX] Cache path issue with subdirectory install
  • [FIX] Minor bugfixes

0.5.8.20 – 2024.02.09.

  • [FIX] Minor bugfixes

0.5.8.19 – 2024.02.01.

  • [FIX] Minor bugfixes
  • [FIX] Bypass cache during CLI request
  • [FIX] Error during save Oxygen and Breakdance
  • [IMPROVE] Remove non-existent pages from warmup table

0.5.8.18 – 2024.01.18.

  • [FIX] Minor bugfixes
  • [FIX] LMS JS conflicts
  • [FIX] Avoid fatal error if WordPress constants are missing
  • [IMPROVE] ACF compatibility
  • [IMPROVE] Breakdance compatibility
  • [IMPROVE] Oxygen builder compatibility

0.5.8.17 – 2023.12.19.

  • [FIX] Minor bugfixes

0.5.8.16 – 2023.12.15.

  • [FIX] Minor bugfixes
  • [FIX] Presto Player compatibility

0.5.8.15 – 2023.12.11.

  • [FIX] bbPress fatal error fix
  • [IMPROVE] Cache management
  • [IMPROVE] CPU usage management
  • [IMPROVE] Borlabs Cookie script blocker compatibility

0.5.8.14 – 2023.11.26.

  • [FIX] Minor Bugfixes
  • [FIX] Shopify compatibility issue

0.5.8.13 – 2023.11.23.

  • [FIX] Minor Bugfixes
  • [FIX] JS Engine conflicts

0.5.8.12 – 2023.11.16.

  • [IMPROVE] LCP & FCP optimization

0.5.8.11 – 2023.11.14.

  • [FIX] BugMonitor compatibility issue

0.5.8.10 – 2023.11.10.

  • [FIX] Minor bugfixes

0.5.8.9 – 2023.11.07.

  • [FIX] Early node issue with JSON requests

0.5.8.8 – 2023.10.26.

  • [FIX] Missing Critical CSS in some cases

0.5.8.7 – 2023.10.13.

  • [FIX] Minor Bugfixes

0.5.8.6 – 2023.10.09.

  • [FIX] Minor Bugfixes

0.5.8.4 – 2023.09.13.

  • [FIX] Minor Bugfixes

0.5.8.3 – 2023.09.07.

  • [FIX] False positive page not cacheable error in toolbar

0.5.8.2 – 2023.09.04.

  • [FIX] Minor Bugfixes
  • [FIX] Subfolder install issues
  • 0.5.8.1 – 2023.09.01.

    • [FIX] Minor Bugfixes
    • [IMPROVE] ReCaptcha compatibility

    0.5.8 – 2023.08.25.

    • [FIX] Minor Bugfixes
    • [FIX] Bricks parralax compatibility
    • [FIX] Website Speedy compatibility
    • [FIX] SureCache compatibility

    0.5.7 – 2023.08.08.

    • [FIX] Minor Bugfixes
    • [IMPROVE] Real Cookie Banner compatibility

    0.5.6.2 – 2023.07.19.

    • [FIX] Minor Bugfixes

    0.5.6 – 2023.07.19.

    • [FIX] Minor Bugfixes
    • [IMPROVE] Fragments WooCommerce compability

    0.5.5.2 – 2023.07.14.

    • [FIX] DHL for WooCommerce compatibility fix
    • [FIX] Code Optimizer WooCommerce missing permalink settings

    0.5.5.1 – 2023.07.13.

    • [FIX] Elementor Lightbox

    0.5.5 – 2023.07.11.

    • [FIX] Minor Bugfixes
    • [FIX] Smart Image Sizing

    0.5.4.1 – 2023.07.10.

    • [FIX] Pixelmate Datacontro compatibility fix

    0.5.4 – 2023.07.07.

    • [FIX] Minor Bugfixes
    • [FIX] Image Optimizer bug with relative URLs
    • [FIX] Pixelmate Datacontrol cache compatibility

    0.5.3 – 2023.07.04.

    • [FIX] Minor Bugfixes

    0.5.2 – 2023.06.28.

    • [FIX] Minor Bugfixes

    0.5.1 – 2023.06.23.

    • [FIX] Minor Bugfixes
    • [FIX] Code Optimizer WooCommerce extensions compatibility

    0.5 – 2023.06.22.

    • [NEW] Code Optimizer (experimental)
    • [FIX] Minor Bugfixes
    • [FIX] Elementor Vimeo Background Videos
    • [FIX] Fix srcset with multiple retina images
    • [FIX] Delete expired transients created by HTTP Request cache
    • [FIX] GIF Optimization errors

    0.4.10 – 2023.05.18.

    • [IMPROVE] Navigation Booster
    • [FIX] JS Engine compatibility issues

    0.4.9 – 2023.05.15.

    • [IMRPOVE] HTML parser
    • [IMRPOVE] CLS Handling
    • [IMRPOVE] Content-Security-Policy compatibility

    0.4.8 – 2023.05.12.

    • [FIX] Minor bugfixes
    • [FIX] Compatibility issue with 404 redirect plugins
    • [IMRPOVE] Add missing alt tags to images

    0.4.7 – 2023.05.11.

    • [FIX] Minor bugfixes
    • [IMPROVE] Iframe Optimization
    • [IMPROVE] 3rd Party Compatibility

    0.4.6 – 2023.05.02.

    • [FIX] Minor bugfixes
    • [FIX] Cache expiry
    • [FIX] Improve image sizes

    0.4.5 – 2023.04.13.

    • [IMPROVE] Critical CSS delivery

    0.4.4 – 2023.04.11.

    • [IMPROVE] Divi compatibility

    0.4.3 – 2023.04.05.

    • [FIX] Beaver Builder compatibility issue

    0.4.2 – 2023.04.05.

    • [FIX] Minor Bugfixes

    0.4.1 – 2023.04.01.

    • [FIX] Activation error

    0.4 – 2023.03.29.

    • [FIX] Minor bugfixes
    • [FIX] WP Grid Builder incompatibility
    • [IMPROVE] Page priority management
    • [IMPROVE] Lazyload Iframes
    • [IMPROVE] Recaptcha compatibility
    • [IMPROVE] More detailed status report on dashboard
    • [IMPROVE] Speed up prebuild process

    0.3.52 – 2023.03.10.

    • [FIX] Minor bugfixes
    • [IMPROVE] Analytics script optimization

    0.3.51.1 – 2023.03.03.

    • [FIX] Minor bugfixes
    • [FIX] Fatal error during optimization on PHP 8+

    0.3.51 – 2023.03.03

    • [FIX] Minor bugfixes
    • [FIX] Jet Plugins product slider compatibility issues
    • [FIX] Prebuild loop

    0.3.50 – 2023.02.27.

    • [FIX] Minor bugfixes

    0.3.48 – 2023.02.20.

    • [FIX] Youtube embed issues

    0.3.47 – 2023.02.20.

    • [FIX] Elementor Gallery issue
    • [IMPROVE] Lazyload background images

    0.3.46 – 2023.02.17.

    • [FIX] Minor bugfixes
    • [IMPROVE] Critical assets loading
    • [IMPROVE] Lazyload images

    0.3.45 – 2023.02.13.

    • [FIX] Minor bugfixes
    • [FIX] Hotjar compatibility issues
    • [FIX] Prevent prefetch admin URLs
    • [IMPROVE] Decrease CLS

    0.3.44 – 2023.01.25.

    • [FIX] Minor bugfixes
    • [FIX] Price fragments for variations
    • [NEW] Remote prebuild feature

    0.3.43 – 2023.01.20.

    • [FIX] Minor bugfixes
    • [FIX] Missing Open Graph meta for Facebook
    • [IMPROVE] JS Engine and inline style handler

    0.3.42 – 2023.01.17.

    • [FIX] Minor bugfixes
    • [NEW] Development Mode
    • [IMPROVE] Admin toolbar options added (frontend/backend/everywhere/hidden)

    0.3.41 – 2023.01.15.

    • [FIX] Minor bugfixes
    • [FIX] Keep original images for Twitter cards and Open Graph
    • [FIX] Font optimization issues
    • [IMPROVE] Matamo compatibility

    0.3.40 – 2023.01.13.

    • [IMPROVE] Quriobot compatibility
    • [FIX] Minor bugfixes
    • [FIX] Elementor Image Carousel issue
    • [FIX] Missing Edit With Elementor if Logged in cache is active

    0.3.39 – 2023.01.10.

    • [FIX] Minor bufgixes
    • [IMPROVE] Improve font optimization
    • [IMPROVE] CDN Enabler compatibility

    0.3.38 – 2023.01.08.

    • [FIX] Critical CSS & FOUC issues

    0.3.37 – 2023.01.06.

    • [FIX] Minor bugfixes

    0.3.36 – 2023.01.04.

    • [FIX] Minor bugfixes

    0.3.35 – 2022.12.30.

    • [NEW] Logged in cache
    • [NEW] Collage feature
    • [FIX] Minor bugfixes

    0.3.34 – 2022.12.28.

    • [FIX] Minor bugfixes

    0.3.33 – 2022.12.26.

    • [IMPROVE] WP Featherlight compatibility
    • [IMPROVE] etracker Analytics compatibility

    0.3.32 – 2022.12.21.

    • [IMPROVE] Presto Player compatibility
    • [IMPROVE] Iframe lazyload compatibility
    • [FIX] Infinite loop symlink

    0.3.31 – 2022.12.20.

    • [FIX] Web Worker error

    0.3.30 – 2022.12.16.

    • [FIX] Responsive WebP background images
    • [FIX] Minor bugfixes
    • [IMPROVE] Critical CSS generation

    0.3.29 – 2022.12.09.

    • [FIX] Elementor JS Optimizer conflict
    • [IMPROVE] Optimize background images

    0.3.28 – 2022.12.08.

    • [FIX] Query Monitor issue
    • [NEW] HTTP API cache

    0.3.27 – 2022.12.07.

    • [FIX] LiteSpeed cache stucked at 80%

    0.3.26 – 2022.12.07.

    • [IMPROVE] JS Optimization engine third party compatibility
    • [IMPROVE] WPML support
    • [IMPROVE] Compatibility with managed hostings

    0.3.25 – 2022.12.06.

    • [IMPROVE] Load full CSS before JS execution if necessary

    0.3.24 – 2022.12.06.

    • [IMPROVE] JS Optimization Engine
    • [IMPROVE] Third Party Compatibility (plugins using output buffer)
    • [FIX] Lazyload Background Images issue

    0.3.23 – 2022.11.29.

    • [IMPROVE] Iframe optimizer
    • [IMPROVE] Jetpack compatibility

    0.3.22 – 2022.11.25.

    • [IMPROVE] JS Optimization Engine
    • [FIX] typo in WooCommerce module

    0.3.20 – 2022.11.23.

    • [FIX] third party javascript optimization conflicts
    • [FIX] Elementor double init issue

    0.3.19 – 2022.11.22.

    • [FIX] source mapping issues in JS engine

    0.3.18 – 2022.11.22.

    • [FIX] Improve JS engine compatibility

    0.3.17 – 2022.11.21.

    • [FIX] Minor bugfixes

    0.3.16 – 2022.11.21.

    • [FIX] Gateway fo Braintree Payments compatibility issue

    0.3.15 – 2022.11.21.

    • [FIX] Fatal error when $urls empty

    0.3.14 – 2022.11.21.

    • [RELEASE] Public beta release

    This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

    Accept All Accept Required Only