Originally published at: Caching Facebook Query Parameters/Strings with Nginx - Managing WP
Introduction When someone shares a link on Facebook, the link they click includes an extra query string, like the following. Nginx Error: setrlimit(RLIMIT_NOFILE, 25562325) failed (1: Operation not permitted) - Managing WP This is problematic because common Nginx configurations will not cache URLs with a query string, and it’s even worse when a site is using WordPress, as these queries will result in a dynamic request.…
Hey!
Step 2 is missing semicolon.
# #
# GridPane vHost FastCGI caching per site include
# Version 1.2.0
# #
# fbutm: If fbclid is in url, set $cache_uri to $path_uri and set $skip_reason, also update fastcgi_cache_key
if ($args ~* "(utm_|gclid|fbclid|utm|gad_source)" ) {
set $cache_uri $path_uri;
# set $skip_reason "${skip_reason}-fbutm-${cache_uri}-${uri}"; # Used for debugging
set $skip_reason "${skip_reason}-fbutm";
}
#fastcgi_cache_key "$scheme$request_method$geoip2_data_country_code$host$request_uri";
fastcgi_cache_key "$scheme$request_method$host$cache_uri";
fastcgi_cache_valid 200 300s;
Step 4
Space in the file name/location - should be /etc/nginx/extra.d/fbutm-skip-fcgi-cache-context.conf
And later a parenthesis
# fbutm: If we see fbclid in $args, don't skip cache and set skip reason
if ($args ~* "(utm_|gclid|fbclid|utm|gad_source)" ) {
set $skip_cache 0;
#set $skip_reason "${skip_reason}-fbutm-${cache_uri}"; # For debugging
set $skip_reason "${skip_reason}-fbutm";
}
# if you have queries that shouldn't be cached
if ($args ~* "(listing_type|product_color)") {
set $skip_cache 1;
set $skip_reason "-querystring-fbutm-bypass";
}
And still in the end it did not work for me at all
Random string on fbclid always gave me miss and later a hit. Since it’s random all the time I gave up
Please leave comments below!