FlyingPress Advanced Setup: Settings, Filters, and Code Running on My Sites

FlyingPress ships with settings that work for most sites. On the UX side, it has fewest settings possible. But beneath that simple settings paradigm, there exists an endless possibility of customizations using PHP filters, manual exceptions and whatnot.

The plugin documentation has around 30 hooks and filters. These let you control exactly how FlyingPress handles your cache, optimizes your assets, and purges outdated content. You don’t need to be a PHP wizard to use them. Copy, paste, tweak a few values, and you’re done.

I’ll share every filter I have used in production, my exact settings from Gaurav Tiwari, and the code snippets running on my own and client sites right now. This isn’t theory. This is what powers sites serving 100K+ of pageviews daily.

My FlyingPress Settings (The Actual Config)

Before we get to filters, here’s how I configure FlyingPress on Gaurav Tiwari. I’ll explain the reasoning behind each choice. If you are not a FlyingPress customer yet, go get it. It’s better than WP Rocket, tbh. Read my full FlyingPress review here.

CSS & JavaScript

SettingValueWhyRecommended for You
Minify CSS/JS✅ EnabledBasic optimization. No reason to skip this.Enable
Remove Unused CSS❌ DisabledI actively develop my theme (Marketers Delight) with proper optimizations built in. RUCSS adds complexity I don’t need. On client sites where I don’t control the theme, I enable this.Enable
Delay JavaScript✅ Enabled (Defer)Defer is safer than delay-all. Scripts load after HTML parsing without blocking render.Enable (Defer)
JS Delay Exclusionsjquery.js, jquery.min.js, stats script, scripts.jsjQuery breaks everything if delayed. My analytics script needs to run immediately for accurate data.Same as mine
Delay Third-Party JS❌ DisabledToo aggressive. Breaks payment forms, chat widgets, and tracking pixels.Same as mine
Self-Host Third-Party❌ DisabledI handle this manually with specific filters for better control.Enable

The RUCSS decision: On Gaurav Tiwari, I know exactly what CSS loads and why. Every style serves a purpose. Remove Unused CSS would just add processing overhead. On client sites running themes like Astra, Blocksy and plugins like Elementor, starter templates etc. with bloated CSS, RUCSS cuts 200-400KB easily. Context matters.

Images & Media

SettingValueWhy
Lazy Load✅ EnabledStandard practice. No above-fold images get lazy loaded anyway.
Properly Size Images✅ EnabledServes appropriately sized images based on viewport. Free Core Web Vitals win.
YouTube Placeholder✅ EnabledYouTube embeds add 1-2MB of resources. Placeholder loads a 20KB image instead until clicked.
Self-Host Gravatars✅ EnabledGravatar requests are slow. Self-hosting eliminates external DNS lookup.
Image CompressionLosslessI pre-optimize images before upload. Lossless preserves quality while stripping metadata.
Image FormatOriginalI upload WebP manually. Automatic conversion sometimes causes issues with transparent PNGs.
Auto-Optimize Uploads✅ EnabledCatches images I forget to optimize before upload.

Fonts

SettingValueWhyRecommended for You
Preload Fonts❌ DisabledI preload critical fonts manually in my theme for precise control.Enable
Optimize Google Fonts❌ DisabledI self-host all fonts. No Google Fonts on my site.Enable
Font Display Swap❌ DisabledAlready set in my font-face declarations.Enable

Self-hosting fonts is non-negotiable. Google Fonts means:

  • DNS lookup to fonts.googleapis.com
  • Connection to fonts.gstatic.com
  • Potential GDPR issues in EU
  • No control over caching headers

I download the fonts, subset them to characters I actually use, and serve them from my own domain. 400KB font files become 40KB. That’s a different article, but trust me on this one.

Caching

SettingValueWhy
Link Prefetch✅ EnabledPreloads pages when users hover over links. Makes navigation feel instant.
Mobile Cache❌ DisabledMy site is responsive. Same HTML works for all devices. Separate mobile cache just fragments storage.
Logged-in Cache❌ DisabledLogged-in users see personalized content. Caching would show wrong data.
Cache Refresh✅ DailyAutomatically rebuilds cache every 24 hours. Keeps content fresh without manual purging.
Bypass URLs/go/, sjv.ioAffiliate redirect URLs should never be cached. They need to track clicks in real-time.

CDN & Cloudflare

SettingValueWhy
CDN✅ EnabledNo reason to skip this.
CDN TypeCloudflareI use Cloudflare for DNS, SSL, and edge caching. FlyingPress integrates natively.
CDN File TypesAllCSS, JS, images, fonts. Everything goes through Cloudflare.

Bloat Removal

SettingValueWhy
Disable Block CSS❌ DisabledI use Gutenberg blocks. Need the styles.
Disable Dashicons✅ EnabledOnly needed in admin. Frontend doesn’t use them.
Disable Emojis✅ EnabledRemoves wp-emoji-release.min.js. I use actual emoji characters, not WordPress’s script.
Disable jQuery Migrate✅ EnabledCompatibility layer for old jQuery code. My site doesn’t need it.
Disable XML-RPC✅ EnabledSecurity risk. I don’t use apps that need XML-RPC.
Disable RSS Feed❌ DisabledPeople actually subscribe to my RSS feed. Don’t break this.
Disable oEmbeds❌ DisabledI embed tweets and YouTube videos. Need oEmbed functionality.

Why FlyingPress Filters Matter

The settings panel gets you 80% there. Filters get the remaining 20% that separates “fast enough” from “consistently under 400ms.”

Here’s what filters solve that settings can’t:

  • UTM parameters fragmenting cache into chaos
  • Cloudflare APO purge conflicts
  • Translation plugins creating weird cache paths
  • Custom auto-purge rules for related content
  • Post-optimization HTML modifications

The Complete FlyingPress Hooks Reference

I’ve organized these by function, not by where they appear in the code. Each section includes the filter name, what it controls, when you’d use it, and working code you can copy.

Cache Purging Hooks

These fire when FlyingPress clears cached pages. Use them to sync external CDNs, log cache events, or trigger custom cleanup.

flying_press_purge_urls:before and flying_press_purge_urls:after

Fires before and after purging multiple URLs. The $urls parameter contains an array of URLs being cleared.

add_action('flying_press_purge_urls:after', function($urls) {
    // Notify Cloudflare or another edge cache
    foreach ($urls as $url) {
        wp_remote_post('https://your-webhook.com/purge', [
            'body' => ['url' => $url],
            'blocking' => false
        ]);
    }
}, 10, 1);

I use this to sync FlyingPress purges with external systems. When a post updates, both caches clear simultaneously. No stale content.

flying_press_purge_url:before and flying_press_purge_url:after

Same concept, but for single URL purges. Useful when you need per-URL logic.

flying_press_purge_pages:before and flying_press_purge_pages:after

Fires when clearing all HTML pages (not static assets). Good for pausing non-essential operations during full purges.

flying_press_purge_everything:before and flying_press_purge_everything:after

The nuclear option. These fire when you purge absolutely everything, including static asset cache. I use the :after hook to trigger full cache warming:

add_action('flying_press_purge_everything:after', function() {
    // Schedule cache warming after full purge
    wp_schedule_single_event(time() + 60, 'custom_warm_cache');
});

Cache Configuration Filters

These control how FlyingPress generates and stores cache files. Critical for multilingual sites, membership sites, and anything with user-specific content.

flying_press_ignore_queries

This filter prevents UTM parameters and tracking codes from fragmenting your cache. By default, FlyingPress ignores common ones (gclid, fbclid, utm_source, etc.), but your marketing team probably uses custom ones.

add_filter('flying_press_ignore_queries', function($queries) {
    return array_merge($queries, [
        'ref',
        'campaign_id',
        'mc_cid',
        'mc_eid',
        'mkt_tok',
        'trk',
        'affiliate',
        '_hsenc',
        '_hsmi',
        'hsa_acc',
        'vgo_ee',
        'wickedid'
    ]);
});

Without this, yoursite.com/?ref=twitter and yoursite.com/?ref=facebook create separate cache files. That’s cache fragmentation. Your server rebuilds pages for no reason.

flying_press_cache_include_cookies

Creates separate cache variants based on cookie values. Useful for A/B testing or user preference cookies.

add_filter('flying_press_cache_include_cookies', function($cookies) {
    return ['ab_test_variant', 'currency_preference'];
});

Now visitors with ab_test_variant=a see one cached version, while ab_test_variant=b see another. No dynamic page generation required.

flying_press_cache_file_path

Modify cache directory structure. Translation plugins like WPML sometimes need this:

add_filter('flying_press_cache_file_path', function($path) {
    // Ensure language prefix is included in cache path
    $lang = apply_filters('wpml_current_language', 'en');
    return $lang . '/' . ltrim($path, '/');
});

flying_press_cache_file_name

Final control over cache filename. Add prefixes, versions, or custom identifiers:

add_filter('flying_press_cache_file_name', function($filename) {
    return 'v2_' . $filename;
});

flying_press_request_uri

Intercepts the request URI before cache path generation. WPML and Polylang integrations often need this to translate URLs correctly:

add_filter('flying_press_request_uri', function($uri) {
    // Strip language directory for cache consistency
    return preg_replace('#^/(en|de|fr)/#', '/', $uri);
});

flying_press_cache_excluded_roles

Skip caching for specific user roles. Editors and admins are excluded by default, but you might need to exclude custom roles:

add_filter('flying_press_cache_excluded_roles', function($roles) {
    return ['subscriber', 'customer', 'premium_member'];
});

flying_press_is_cacheable

The final gate. Return false to prevent caching based on custom logic:

add_filter('flying_press_is_cacheable', function($cacheable) {
    // Don't cache WooCommerce cart or checkout
    if (function_exists('is_cart') && is_cart()) {
        return false;
    }
    if (function_exists('is_checkout') && is_checkout()) {
        return false;
    }

    // Don't cache pages with specific shortcodes
    global $post;
    if ($post && has_shortcode($post->post_content, 'user_dashboard')) {
        return false;
    }

    return $cacheable;
});

flying_press_footprint

Customize or remove the HTML comment FlyingPress adds to cached pages:

add_filter('flying_press_footprint', function($footprint) {
    // Remove footprint entirely
    return '';
});

I remove the footprint on client sites. No need to advertise which caching plugin you use.

Auto Purge Control

flying_press_auto_purge_urls

When a post updates, FlyingPress purges related URLs automatically. This filter lets you add more:

add_filter('flying_press_auto_purge_urls', function($urls, $post_id) {
    // Get the post's categories
    $categories = wp_get_post_categories($post_id);

    foreach ($categories as $cat_id) {
        $urls[] = get_category_link($cat_id);
    }

    // Add sitemaps
    $urls[] = home_url('/sitemap_index.xml');
    $urls[] = home_url('/sitemap.xml');

    // Add custom related pages
    $urls[] = home_url('/blog/');

    return $urls;
}, 10, 2);

This ensures your category archives and sitemap update when you publish or edit posts. No stale “recent posts” lists.

Preloading Configuration

flying_press_preload_urls

Control which URLs get preloaded (cache warmed):

add_filter('flying_press_preload_urls', function($urls) {
    // Add high-priority pages first
    $priority_pages = [
        home_url('/'),
        home_url('/pricing/'),
        home_url('/features/'),
        home_url('/blog/')
    ];

    return array_merge($priority_pages, $urls);
});

flying_press_preload_delay

Throttle preload requests. The default is 0.5 seconds between requests. On shared hosting, slow it down:

add_filter('flying_press_preload_delay', function($delay) {
    return 1.0; // 1 second between requests
});

On a fast dedicated server, speed it up:

add_filter('flying_press_preload_delay', function($delay) {
    return 0.2; // 200ms between requests
});

Asset Optimization Filters

flying_press_exclude_from_minify:js

Some JavaScript breaks when minified. Exclude problematic scripts:

add_filter('flying_press_exclude_from_minify:js', function($exclude) {
    return array_merge($exclude, [
        'jquery.min.js',
        'recaptcha',
        'gtag',
        'fbevents.js',
        'hotjar',
        'clarity'
    ]);
});

Match by partial filename or URL. If recaptcha appears anywhere in the script URL, it won’t be minified.

flying_press_exclude_from_minify:css

Same for CSS files:

add_filter('flying_press_exclude_from_minify:css', function($exclude) {
    return array_merge($exclude, [
        'font-awesome',
        'dashicons',
        'admin-bar'
    ]);
});

flying_press_optimization:after

The most powerful filter. Runs after all optimizations, giving you final control over the HTML output:

add_filter('flying_press_optimization:after', function($html) {
    // Minify all inline CSS
    $html = preg_replace_callback(
        '/";
        },
        $html
    );

    return $html;

}, 99);

This minifies inline styles that FlyingPress doesn’t touch by default.

External Resource Handling

flying_press_selfhost_external_domains

FlyingPress can download and self-host external CSS/JS from CDNs like jsDelivr and cdnjs. Add more domains:

add_filter('flying_press_selfhost_external_domains', function($domains) {
    return array_merge($domains, [
        'fonts.googleapis.com',
        'use.fontawesome.com',
        'kit.fontawesome.com'
    ]);
});

Self-hosting eliminates third-party DNS lookups and connection times. Google Fonts alone can add 200-400ms.

flying_press_download_external_file:before

Modify external files before FlyingPress saves them locally:

add_filter('flying_press_download_external_file:before', function($content, $url, $type) {
    if ($type === 'css') {
        // Fix relative font paths in downloaded CSS
        $base_url = dirname($url);
        $content = preg_replace(
            '/url\s*\(\s*[\'"]?(?!data:|https?:|\/\/)([^\'")]+)[\'"]?\s*\)/i',
            'url("' . $base_url . '/$1")',
            $content
        );
    }
    return $content;
}, 10, 3);

Access Control

flying_press_allowed_roles

By default, only administrators and editors can access FlyingPress settings. Expand or restrict:

add_filter('flying_press_allowed_roles', function($roles) {
    return ['administrator']; // Admins only
});

Configuration Change Hooks

flying_press_update_config:after

Fires after FlyingPress settings are saved. Useful for rebuilding related caches:

add_action('flying_press_update_config:after', function($new_config, $old_config) {
    // Log configuration changes
    if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
        error_log('FlyingPress config updated by user ' . get_current_user_id());
    }

    // Purge Cloudflare when settings change
    if ($new_config !== $old_config) {
        do_action('cloudflare_purge_everything');
    }
}, 10, 2);

flying_press_upgraded

Fires after plugin upgrades. Run migration scripts or rebuild caches:

add_action('flying_press_upgraded', function() {
    // Purge all caches after upgrade
    if (class_exists('FlyingPress\Purge')) {
        FlyingPress\Purge::purge_everything();
    }
});

Image Optimization

flying_press_image_optimizer_delay

Control throttling between image optimization API calls:

add_filter('flying_press_image_optimizer_delay', function($delay) {
    return 1.0; // Slower for shared hosting
});

flying_press_optimization_image_ids

Filter which images get optimized:

add_filter('flying_press_optimization_image_ids', function($ids) {
    // Only optimize images over 50KB
    return array_filter($ids, function($id) {
        $file = get_attached_file($id);
        return $file && filesize($file) > 50000;
    });
});

My Production Configuration

Here’s the complete mu-plugin I use on most sites. Drop this in wp-content/mu-plugins/flyingpress-customizations.php:

]*)>(.*?)<\/style>/is',
        function($matches) {
            $css = $matches[2];
            if (strpos($css, "\n") === false) return $matches[0];
            $css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
            $css = preg_replace('/\s+/', ' ', $css);
            $css = preg_replace('/\s*([:;{},>~+])\s*/', '$1', $css);
            $css = preg_replace('/;}/', '}', $css);
            return "";
        },
        $html
    );
}, 99);

// Restrict access to admins only
add_filter('flying_press_allowed_roles', function($roles) {
    return ['administrator'];
});

Common Problems These Filters Solve

ProblemSolution
Cache fragmentation from affiliate linksAdd affiliate parameter names to flying_press_ignore_queries
Cloudflare serves stale content after updatesUse flying_press_purge_urls:after to sync purges with Cloudflare API
Membership content getting cachedUse flying_press_cache_excluded_roles for member roles
Third-party scripts break after minificationAdd patterns to flying_press_exclude_from_minify:js
WPML creates duplicate cache filesUse flying_press_request_uri to normalize paths
Category archives show old post listsAdd category URLs to flying_press_auto_purge_urls
Inline CSS not minifiedUse flying_press_optimization:after to post-process HTML

FlyingPress vs WP Rocket: The Filter Difference

I used WP Rocket for nearly a decade before switching. Both plugins have filters, but FlyingPress exposes more of its internals. The flying_press_optimization:after filter alone gives you control WP Rocket doesn’t offer without modifying core files.

If you’re deciding between them, read my FlyingPress review and my breakdown of WP Rocket alternatives. For pure speed and developer control, FlyingPress wins. For set-and-forget simplicity, WP Rocket is still solid.

Where to Add This Code

Three options, ranked by preference:

  1. Must-use plugin (recommended): Create wp-content/mu-plugins/flyingpress-custom.php. Loads automatically, survives theme changes, can’t be accidentally deactivated.
  2. Code Snippets plugin: Use a plugin like Code Snippets to manage PHP additions through the admin. Less clean but easier for non-developers.
  3. Theme functions.php (avoid): Works, but you lose customizations when changing themes. Only use this for testing.

Never edit FlyingPress plugin files directly. Updates will overwrite your changes.

Frequently Asked Questions

Do I need to know PHP to use FlyingPress filters?

Not really. Copy the code snippets from this guide, change the values to match your needs, and paste them into a must-use plugin file. If you can edit a text file, you can use these filters.

Will these filters break if FlyingPress updates?

Unlikely. Hooks and filters are part of WordPress’s extension API. Plugin developers keep them stable because breaking changes would affect thousands of sites. I’ve used these same filters across multiple FlyingPress versions without issues.

Can I use multiple filters together?

Yes. Combine as many as you need. Put them all in one mu-plugin file. They won’t conflict with each other since they hook into different parts of the caching process.

What’s the flying_press_optimization:after filter priority?

Use priority 99 or higher to ensure your modifications run after FlyingPress completes its optimizations. Lower priorities run earlier in the chain and might get overwritten by default behavior.

How do I know if my filter is working?

View page source and look for your changes. For cache-related filters, check the wp-content/cache/flying-press/ directory. For logging, add error_log() statements and check your debug.log file.

Does FlyingPress support WooCommerce out of the box?

Yes. Cart and checkout pages are excluded automatically. But if you have custom membership or account functionality, use the flying_press_is_cacheable filter to exclude those pages based on your specific logic.

Should I enable Remove Unused CSS?

Depends on your theme. If you’re using a bloated theme or page builder, yes. RUCSS can cut 200-400KB of unused styles. If you control your theme’s CSS and it’s already optimized, skip it. RUCSS adds processing overhead and can occasionally break styles on dynamic content.

Why bypass cache for /go/ URLs?

The /go/ directory contains affiliate redirect links. These need to execute PHP to track clicks, add cookies, and redirect to the affiliate URL. If cached, the redirect would be served as a static file and none of the tracking would work. Your affiliate commissions would disappear.

Start With One Filter

Don’t implement everything at once. Pick the filter that solves your most annoying problem. For most sites, that’s flying_press_ignore_queries to stop UTM parameter chaos.

Once you see how much control these filters give you, you’ll understand why I switched from WP Rocket. The default settings are fast. The filters make it yours.

Grab FlyingPress if you haven’t already. Then come back here and start customizing.

Disclaimer: My content is reader-supported, meaning that if you click on some of the links in my posts and make a purchase, I may earn a small commission at no extra cost to you. These affiliate links help me keep the content on gauravtiwari.org free and full of valuable insights. I only recommend products and services that I trust and believe will genuinely benefit you. Your support through these links is greatly appreciated—it helps me continue to create helpful content and resources for you. Thank you! ~ Gaurav Tiwari