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.
Table of Contents
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:
- fbclid
- ref
- utm*
In FlyingPress
FlyingPress automatically ignores the following query strings:
- age-verified
- ao_noptimize
- usqp
- cn-reloaded
- sscid
- ef_id
- s_kwcid
- _bta_tid
- _bta_c
- dm_i
- fb_action_ids
- fb_action_types
- fb_source
- fbclid
- utm_id
- utm_source
- utm_campaign
- utm_medium
- utm_expid
- utm_term
- utm_content
- _ga
- gclid
- campaignid
- adgroupid
- adid
- _gl
- gclsrc
- gdfms
- gdftrk
- gdffi
- _ke
- trk_contact
- trk_msg
- trk_module
- trk_sid
- mc_cid
- mc_eid
- mkwid
- pcrid
- mtm_source
- mtm_medium
- mtm_campaign
- mtm_keyword
- mtm_cid
- mtm_content
- msclkid
- epik
- pp
- pk_source
- pk_medium
- pk_campaign
- pk_keyword
- pk_cid
- pk_content
- redirect_log_mongo_id
- redirect_mongo_id
- sb_referer_host
- ref
You can also add your own query strings to exclude from caching:
In WP Rocket
WP Rocket automatically ignores the following query strings:
- All UTM tags (utm*)
- fb_action_ids
- fb_action_types
- fb_source
- fbclid
- _ga
- gclid
- age-verified
- ao_noptimize
- usqp
- cn-reloaded
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.
Conclusion
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 within 8 hours!
Comments are closed.