Swift-Performance-vs.-WP-Rocket-Poll
WordPress,  Wordpress Plugins

The Ideal Swift Performance Settings With Cloudflare + StackPath CDN Setup Instructions (2019, Version 2.0.5)

Swift Performance is the new cache plugin on the block, which has been getting raving reviews in the WordPress Speed Up Facebook Group.

I’ve been using WP Rocket and already had 100% GTmetrix scores with a 1s load time (hard to beat), but Swift gave me near identical results. I stuck with WP Rocket, but I would rate Swift Performance Lite the #1 free cache plugin ahead of WP Fastest Cache, WP Super Cache, W3 Total Cache, and the others. The Swift Performance settings are relatively easy to setup (I’ll walk you through everything). The Pro Version includes an image optimizer (for lossless compression + automatic image resizing), critical fontscompute API, and support for their plugin. Cool part is, they have an option to pay monthly so you can try it for only $3.99/month.

Swift vs. WP Rocket – these are usually the top cache plugins in recent Facebook polls…

Swift-Performance-vs.-WP-Rocket-Poll

Swift-Performance-vs.-WP-Rocket

Swift

  • Free (lite) version = amazing results
  • Mediocre documentation
  • Free version includes plugin organizer
  • Pro version includes critical fonts
  • Pro version includes image optimizer
  • Free

WP Rocket

  • Easier to configure
  • Better documentation
  • Facebook Pixel + Sucuri add-ons
  • No plugin organizer
  • No image optimizer
  • $39/year

Both Swift and WP Rocket support Cloudflare, CDN, heartbeat control, preloading, lazy loading photos/iframes, hosting Google Analytics locally, minification, script merging, gzip compression, and other features. They are actually very similar as far as their features go.

 

1. Wizard

The Wizard analyzes your site and helps configure basic Swift Performance settings. The out-of-the-box settings work great, but there are still more ways to optimize when you’re done…

Things You Still Need To Do

  • Tweaks → Cache Gravatars
  • Hearbeat → Disable All
  • Google Analytics → Bypass Google Analytics
  • Styles → Generate Critical CSS
  • Caching → General → Separate Mobile Device Cache (if using AMP or mobile theme)
  • Varnish → Custom Host
  • CDN → StackPath CDN
  • CDN → Sign up for Cloudflare and change name servers
  • Optimize Images (using Swift Pro or Imagify/Imsanity)
  • Database Optimizer → clean database
  • Plugin Organizer → enable/disable plugins on specific content

Swift-Performance-Lite-Setup-Wizard-Analyze-Your-Site

Swift-Performance-Lite-Setup-Wizard-Caching-Method

Swift-Performance-Lite-Setup-Wizard-Optimization

Swift-Performance-Lite-Setup-Wizard-Medi

Swift-Performance-Setup-Wizard-Finish

 

2. Dashboard

The dashboard shows stats, like how many known pages Swift detected vs. how many are actually cached. Swift also assigns each URL a prebuild priority and the date eache page was last cached. In the Warmup table, you can also manually add URLs if Swift didn’t detected it.

Swift-Performance-Dashboard

 

3. Settings

The general, media, optimization, caching, and CDN tabs are broken down into sections:

 

3.1. General

General

  • Disable Cookies – for GDPR when asking users to agree to cookies.
  • Hide Footprints – hide swift comments in the source code.
  • Use Compute API – speeds up merge settings and decreases CPU usage.
  • Enable Remote Cron – Swift’s API server will call wp-cron.php and run WP cronjobs as real cronjobs.
  • Debug Log – see warnings/errors shown in the log path (eg. public HTML folder).

Swift-Performance-General-Settings

Tweaks

  • Normalize Static Resources – attempts to remove query strings, however these are usually generated by slow plugins. The main way to get rid of them is to deactivate high CPU plugins (found in GTmetrix Waterfall) and replace them with lightweight plugins.
  • Prefetch DNS – anticipates external resources (eg. Google Fonts + YouTube videos).
  • Collect domains from scripts – helps with prefetching DNS.
  • Exclude DNS Prefetch – exclude domains you don’t want to be prefetched.
  • Gravatar Cache – caching Gravatars usually isn’t enough, you also want to offload them to a CDN and load Gravatars locally as explained in WP Rocket’s Gravatar tutorial. This improves load times for posts with lots of comments, as some of my posts have 300+ comments where Gravatars have suck up over 50% of load times.
  • Gravatar Cache Expiry – time Gravatar cache will expire (3600 is fine for most sites) but you can increase this if you notice it’s consuming too much CPU. If too high, users will never see the cached version. If too low, it can consume too much CPU.
  • Custom Htaccess – setup redirects or use it for other things.

Swift-Performance-Tweaks-Settings

Heartbeat
Speeds up WordPress admin and reduces CPU by disabling the Heartbeat API. This notifies users when content is being edited and allows plugins to send real-time notifications (adding requests). Disabling it saves CPU (WP Disable + Heartbeat Control plugin do the same thing).

Swift-Performance-Heartbeat-Settings

Google Analytics
Bypassing Google Analytics can fix items in GTmetrix/Pingdom related to Google Analytics. CAOS, WP Disable, and WP Rocket’s Google Tracking add-on also help fix items related to GA.

 

3.2. Media

Images

  • Optimize Images on Upload – losslessly compress images which fixes “optimize images” in GTmetrix (only for the page you test). Imagify does this too and is what I use.
  • JPEG quality – keep at 100% to avoid lossy compression.
  • PNG quality – keep at 100% to avoid lossy compression.
  • Resize Large Images – resizes large imager to correct dimensions (many people upload oversized images). This fixes “serve scaled images” in GTmetrix. Imsanity does this too.
  • Keep Original Images – when Swift resizes large images, it will keep the original in case the new image isn’t the size you want it, so at least you have a backup of each image.
  • Inline Small Images – small external images are written directly into the HTML document, so the browser does not request those image files independently.
  • Lazyload – only loads images once you scroll down the page and actually see them. While this improves initial load times, it also means users constantly see images loading as they scroll down, which can be annoying. That’s why I only lazy load videos + iframes.
  • Force Responsive Images – uses the srcset attribute to provide several image sources for browsers so they can pick the right one.

Swift-Performance-Images-Settings

Embeds

  • Lazy Load Iframes – only loads iframes once you scroll down and see them.
  • Exclude Iframes – exclude certain iframes from being lazy loaded.
  • Load Iframes on User Interaction – only loads iframes when users interact with it (using the mouse move, roll, or touchstart).

Swift-Performance-Embeds-Settings

 

3.3. Optimization

General

  • Merge Assets for Logged in Users – disable, as it doesn’t improve load times and will likely do more harm than good, plus most optimizations should be on front-end.
  • Optimize Prebuild Only – disable unless you want to control when cache is built.
  • Optimize in Background – Swift will optimize pages in the background.
  • Fix Invalid HTML – some plugins/themes use invalid HTML, Swift will try to fix this.
  • Minify HTML – fixes multiple items in GTmetrix/Pingdom. Cloudflare takes care of this too, so you should only have 1 enabled (Swift or Cloudflare).
  • Disable Emojis – emojis add requests and hurt load times.
  • Limit Simultaneous Threads – speed of cache rebuild (lower if having CPU issues).
  • Maximum Threads – lower numbers = less CPU usage (2 is good).
  • DOM Parser Max Buffer – Swift developer set this numbers for a reason.

Swift-Performance-General-Optimization-Settings

Scripts
Merging/minifying JavaScript is notorious for causing errors, but I would test these and check your load times. If you see errors, find the problematic files and add them to ‘Exclude Scripts.’

  • Merge Scripts – many people say disable it, but I would test it.
  • Async Execute – JavaScript will theoretically load as 1 request and will be executed while the script is still loading, but it can also break things, so test option carefully.
  • Exclude 3rd Party Scripts – enable if using Merge Scripts, disable if you’re not.
  • Exclude Scripts – exclude problematic files if minifying JavaScript results in errors.
  • Exclude Inline Scripts – exclude problematic files if Merge Scripts results in errors.
  • Exclude Script Localizations – Swift developer recommends enabling it, otherwise you may have separate JavaScript files for all your pages.
  • Minify Javascripts – enable and check your site. If you see errors, exclude problematic files under Exclude Scripts (Cloudflare also does this, so only enable one).
  • Minify with API – enable only if default Minify JavaScripts option results in errors.
  • Proxy 3rd Party Assets – Swift says it can fix browser cache issues in GTmetrix related to GA, but can break scripts. Bypassing Google Analytics is a better option. Test it out.
  • Separate Scripts – saves merged JS files for pages separately. Generally this consume more CPU than it does good.
  • Print merged scripts inline – only enable if using memcached and WordPress can’t write your files.
  • Lazy Load Scripts – lazy loads external resources which can improve load times.
  • Include Scripts – include certain scripts not detected by Swift.

Swift-Performance-Scripts-Settings

Styles
CSS optimization can also cause errors, but can greatly improve scores/load times. Play with the settings and check a few pages to make sure everything is OK. If merging stylesheets and minifying CSS cause errors, locate/exclude problematic files (same things with JavaScript).

  • Merge Styles – recommended by Swift developer and fixes items in GTmetrix/Pingdom.
  • Generate Critical CSS – CSS will be loaded asynchronously, however the developer says this can increase CPU.
  • Print full CSS inline – developer says you shouldn’t need this.
  • Separate Styles – disable unless you have pages with different content types (eg. some use Visual Editor, some use Page Builders, etc) and need Swift to generate a different merged CSS for each page. May improve scores, but can increase CPU. Test carefully.
  • Minify CSS – enable, but this can cause issues so test your site (Cloudflare also does this, so only use one). If you see errors, exclude problematic files under Exclude Files.
  • Bypass CSS Import – enable (this merges imported CSS files as well).
  • Exclude 3rd Party CSS – if Merge Scripts is giving you problems, try this.
  • Exclude Styles – exclude problematic files if minifying CSS results in errors.
  • Include Styles – manually include styles if you’re not using Merge Scripts.

Swift-Performance-Styles-Settings

 

3.4. Caching

General

  • Enable Caching – enable.
  • Caching Mode – disk cache with rewrites is generally fastest for most sites. If you can’t edit the .htaccess file or Nginx config, use Disk cache with PHP. If memcached is installed, select memcached with PHP, but always try to use disk cache with rewrites.
  • Early Loader – enable unless it’s causing PHP issues.
  • Cache Path – specify directory for the cache path.
  • Cache Expiry Mode – time-based is best for nearly every website.
  • Cache Expiry Time – time cache will be regenerated. Too often and it will consume CPU, too little and users won’t see the cached version. 12 hours is good for most sites, but you can decrease this if you have time sensitive content (or clear cache manually).
  • Garbage Collection Interval – how often Swift checks for expired cache pages. 30 minutes is good, too high and it will consume CPU.
  • Clear Cache on Update Post by Page – add pages/posts where you want the cache to be cleared once it is updated, so users can see the new content.
  • Clear Cache on Update Post by URL – same concept as previous settings, only by URL.
  • Enable Caching for logged in users – enable if multiple users are logging into your site (eg. bbPress). This gives each user their own cached version, otherwise keep it disabled.
  • Separate Mobile Device Cache – enable if using AMP or a mobile theme.
  • Case Insensitive URLs – shouldn’t make a difference.
  • Enable Browser Cache – enable.
  • Enable Gzip – fixes gzip items in GTmetrix/Pingdom.
  • Send 304 Header – disable.
  • Cache 404 pages – enable, since spiders may be crawling invalid URLs and consume CPU. Caching 404 pages and serving them from a CDN cuts down on server resources.
  • Ignore Query String – doesn’t cache pages that are different for each user (unique sales pages if you run FB/Google ads, membership profiles, conditional logic on forms).
  • Enable Dynamic Caching – lets you specify cacheable $_GET and $_POST requests.
  • Cacheable AJAX Actions – cache resource-intensive AJAX requests by specifying their names here.
  • AJAX Cache Expiry Time – leave as 1440.

Exceptions
Depending on what assets your site uses, you may not want to cache certain static files (some common ones are eCommerce cart/checkout pages, admin, XML sitemap, and search pages.

  • Exclude URLs – exclude specific URLs from cache.
  • Exclude Content Parts – exclude specific content parts from cache.
  • Exclude User Agents – exclude specific user agents from  cache.
  • Exclude Crawlers – exclude specific crawlers from cache.
  • Exclude Author Pages – exclude specific author pages from cache.
  • Exclude Archive – exclude specific archives pages from cache.
  • Exclude REST URLs – exclude specific REST URLs from cache.
  • Exclude Feed – exclude specific feeds from cache.

Warmup
Warmup stores URLs in for the next cache prebuild. Each URL has a priority number (shown in the dashboard settings) where they can be adjusted manually. Lower number = higher priority.

  • Enable Remote Prebuild Cache – Swift will no longer use an external bot for prebuilding and will use the background process instead.
  • Prebuild Cache Automatically – prebuilds cache after it’s cleared. If using this, also enable “Optimize Prebuild Only.”
  • Discover New Pages – if Swift can’t find all your pages, this will help.
  • Prebuild Author Pages – prebuilds author pages.
  • Prebuild Archive – prebuilds archive pages.
  • Prebuild REST URLs – prebuilds REST URLs.
  • Prebuild Feed – prebuilds RSS feed pages.

Varnish
Enable Auto Purge – enable if using varnish cache – it will automatically purge it when Swift clears the plugin cache so you don’t have to do it manually.

Appcache
Appcache downloads your site (or specific pages) into the user’s browser on their first visit, making your website available even when they’re offline. Sounds great, but this significantly slows down your prebuild and is not worth it. I highly recommend leaving these disabled.

  • Enable Appcache for Desktop – disable.
  • Enable Appcache for Mobile – disable.

 

3.5. CDN

I use StackPath ($10/month with 30-day trial) in conjunction with Cloudflare. StackPath has 31 data centers, Cloudflare has 150+. More data centers = faster content delivery, and StackPath’s are heavily located in the US which is where, at least, most of my visitors are.

StackPath-Data-Centers

General

Step 1: Enable CDN.

Step 2: In the StackPath dashboard, click the CDN tab, and create a StackPath CDN Site

StackPath-CDN-Tab

StackPath-CDN-Domain

StackPath-Server-IP-Address

*Copy your server IP address as it is needed in step 4 of this section.

StackPath-CDN-URL-Swift-Performance

Step 3: Paste your StackPath CDN URL into the CDN Hostname field of Swift Performance.

Swift-Performance-StackPath-CDN-Settings

Step 4: In StackPath go to CDN → Cache Settings, then click “Purge Everything”…

StackPath-Purge-Cache

Step 5Whitelist your server IP address in StackPath (WAF → Firewall).

StackPath-Whitelist-IP

Step 6: Run your site in GTmetrix and “content delivery network” should be green in YSlow.

CDN GTmetrix YSlow

Enable CDN on SSL – enable if using SSL.

SSL CDN Hostname – leave blank since hostnames are the same even if it’s SSL.

Cloudflare

Cloudflare adds even more data centers to your content delivery network…

Cloudflare-Data-Centers

Step 1. Sign up for Cloudflare and you will be prompted to add your site and begin a scan.

cloudflare-begin-scan

Step 2. Once the scan is done, select the free plan, then Cloudflare will take you through a set of pages. You will eventually be taken to a page where Cloudflare assign you 2 name servers.

Cloudflare-Dashboard-Swift-Performance

Step 3. Do a Google search for “how to change name servers on SiteGround” (only search for your host), then follow their instructions. You will be copying the 2 name servers provided by Cloudflare and pasting them into a custom name servers option in your hosting cPanel…

SiteGround-DNS-Records

Step 4. Grab your Cloudflare Global API Key (found in your Cloudflare profile) and enter it into Swift’s Cloudflare tab. Use the same email as your Cloudflare account, and enable auto purge which purges Cloudflare’s cache when Swift’s cache is cleared (so you don’t have to manually).

Swift-Performance-Cloudflare-Settings

MaxCDN / StackPath
You can ignore these options. StackPath bought MaxCDN and they no longer use an Alias, Consumer Key, or Secret. Simply create a StackPath CDN URL and enter it in the CDN tab.

  • MAXCDN Alias – outdated (use StackPath CDN URL).
  • MAXCDN Consumer Key – outdated (use StackPath CDN URL).
  • MAXCDN Consumer Secret – outdated (use StackPath CDN URL).

Swift-Performance-MaxCDN-Settings

 

4. Image Optimizer

Swift Performance’s image optimizer is good, but you don’t need to upgrade for this (you can use free image optimization tools/plugins): ShortpixelImagify, and Imsanity all do a great job.

 

5. Database Optimizer

The database optimizer deletes unused database tables (often left by plugins you uninstalled), transients, autosaves, trashed posts, spam comments, and potentially thousands of post revisions which are automatically stored each time you republish content. For the most part, it’s junk. Take a backup especially if you haven’t done this for awhile, as it cannot be undone.

Swift-Performance-Database-Optimizer

 

6. Critical Font

Critical fonts let you select icons from Font Awesome and efficiently load only the ones you choose, as oppose to the entire Font Awesome library, making these icons load much faster.

Swift-Performance-Critical-Fonts

 

7. Plugin Organizer

In your GTmetrix Waterfall tab, you may notice certain plugins are running on pages/posts where it’s not even being used. Contact Form 7 might be used on your contact page, but usually nowhere else (so it shouldn’t run anywhere else). My WP Review rich snippets plugin do this too. You can disable/enable plugins using Swift’s filters while adding multiple rules.

Swift-Performance-Plugin-Organizer

Examples

  • Enable URL Match /contact/ to only show Contact Form on that page
  • Disable certain plugins in your WordPress Admin to prevent CPU consumption
  • Enable URL Match with regex expression to only show rich snippets on ‘review’ posts

 

8. Upgrade PRO

Swift Pro lets you use their compute API, image optimizer, and critical fonts. Frankly I think they give away too much in their free (lite) plugin, and that these aren’t worth upgrading for.

Swift-Performance-Pro

9. Test Results In GTmetrix

With Swift Performance…
Swift-Performance-GTmetrix-Report

With WP Rocket…
New-GTmetrix-Report.png

 

Conclusion

Swift Performance Lite blows other free cache plugins out of the water, even if you configure just basic settings using the Wizard. If you’re still have issues, see my full WordPress speed optimization guide which includes a list of high CPU plugins to avoid, lightweight plugin alternatives, AMP instructions, how to upgrade to PHP 7+, image optimization, and a link if you want to hire my developer on freelancer.com who helped me get a 100% GTmetrix score.

Nguồn: https://onlinemediamasters.com/swift-performance-settings/

Avatar of Bình Minh

Tui là Nguyễn Xuân Bình Minh

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Website này sử dụng Akismet để hạn chế spam. Tìm hiểu bình luận của bạn được duyệt như thế nào.