Just because you have the highest scores or the fastest fully loaded time doesn’t mean your actual visitors have the fastest site.
You must have set up caching via cache plugins or Cloudflare page rules to cache HTML pages. But are you sure that these cached pages are delivered to your visitors?
In my case, visitors from Facebook were not receiving cached pages.
The problem was, Facebook is appending a query string “fbclid” to all links from Facebook. It’s unique for each user. So every time there is a new “fbclid”, they’re getting uncached pages.
Ignoring Query Strings in Popular Cache Plugins
In LiteSpeed Cache
LiteSpeed Cache caches query strings by default. You can exclude certain keywords by going to LiteSpeed Cache -> Cache ->Drop Query String:
I usually ignore the following:
In WP Rocket
WP Rocket automatically ignores the following query strings:
- All UTM tags (utm*)
Any other query strings like s=something, country=India, ref=google.com etc are served non-cached pages. So if you want any custom query parameters to be ignored, you’ll need to download their helper plugin.
You can read more about WP Rocket‘s query caching here.
In Swift Performance
Swift Performance by default ignores “fbclid” and “gclid“. There is also an option to ignore all other query strings. But will break search and similar pages.
Noway to selectively ignore using keywords.
Will Google Analytics, Facebook and other trackers work after this?
Tracking scripts like Google Analytics, Facebook Pixel etc use these query parameters for various purposes. Since you’re not removing them, these scripts can get those from the URL and do necessary.
Note: For Cloudflare, this doesn’t apply because you’ll need to remove query strings.
Cloudflare Full Page Caching
If you’ve implemented full page caching via rules in Cloudflare, a similar issue exists. Most of your visitors from Facebook and other sites with these query strings are getting uncached pages.
To fix this you’ll need to add a Page Rule that will remove such query strings.
Here is an example rule that will remove “fbclid” query string:
This tells Cloudflare to redirect URLs like https://wpspeedmatters.com/hire-me?fbclid=xxxxxx to https://wpspeedmatters.com/hire-me.
Thanks to Gulshan Kumar for posting this tip in our group.
WP Rocket and Swift Performance handle this really well by default. In LiteSpeed Cache, you just need to add the necessary keywords to exclude list.
However, if you’re using Cloudflare full page caching, you might need to buy additional Page Rules to set it up.
Comment below if you’ve any queries or feedback. I read and reply to each of them!
Great content! Super high-quality! Keep it up! :)