Hi, I had a similar issue with gclid, gbraid, or other tracking parameters that are unique for each user for tracking purposes.
For example:
domain.com/?gclid=d189h9d8h1892819dh198289ashdakjsdh8912721
domain.com/mypage/?gclid=d189h9d8h1892819dh198289ashdakjsdh8912721
domain.com/my-page-2/?gclid=d189h9d8h1892819dh198289ashdakjsdh8912721
These URLs were missing the fastcgi cache instead of serving the cached page:
domain.com/
domain.com/mypage/
domain.com/my-page-2/
To fix this under my current installation of WordOps v3.21.3 on Ubuntu 20.04.6 LTS:
in each step run nginx -t
to check your syntax and when you are done service nginx reload
- Edit /etc/nginx/conf.d/map-wp-fastcgi-cache.conf and add the "gclid" parameter.
'# Cache requests with query strings related to analytics
map $args $args_to_cache {
default 0;
"~*utm_" 1;
"~*fbclid" 1;
"~*gclid" 1;
}
- Then, add the following to the bottom of the file:
map $request_uri $cleaned_request_uri {
~^(.*)\?.*gclid=.*$ $1; # Remove fbclid parameter if present
~^(.*)\?.*fbclid=.*$ $1; # Remove fbclid parameter if present
default $request_uri; # Default to original request URI
}
// to work with utm_* needs somo work but also works ~^(.*)\?(.*&)?(utm_[^&]*)=[^&]*(?:&(.*))?$ $1?$2$4; # Removes only parameters that start with "utm_"
- Now edit /etc/nginx/conf.d/fastcgi.conf:
Comment out:
#fastcgi_cache_key "$scheme$request_method$host$request_uri";
Add:
fastcgi_cache_key "$scheme$request_method$host$cleaned_request_uri";
fastcgi_param REQUEST_URI $cleaned_request_uri; # Add this line above
fastcgi_param SERVER_NAME $http_host;
- Finally, you have two options: either add a new file under /var/www/domain.com/conf/nginx/cache.conf or edit common/wpfc-php82.conf (note that it will be overwritten when you update WO).
try_files $cleaned_request_uri $uri $uri/ /index.php$is_args$args;
Now, fastCGI will always hit the cache if any parameter (gclid or fbclid) is present. It's kind of a workaround, but it works for me.
However, you can always replace the directives in step 2 with:
~^(.*)\?(.*&)?(fbclid|gclid)=[^&]*(?:&(.*))?$ $1?$2$4; # Removes any of the specified parameters
In each step run nginx -t
to check your syntax and when you are done service nginx reload