<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Agus Muhammad</title>
	<atom:link href="https://agusmu.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://agusmu.com</link>
	<description>WordPress/WooCommerce Expert, Digital Marketer, Earth Scientist</description>
	<lastBuildDate>Fri, 23 Oct 2020 11:13:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.5</generator>
	<item>
		<title>Enable Caching Query String on Nginx FastCGI Cache</title>
		<link>https://agusmu.com/nginx-fastcgi-cache-query-string/</link>
					<comments>https://agusmu.com/nginx-fastcgi-cache-query-string/#respond</comments>
		
		<dc:creator><![CDATA[agusmu]]></dc:creator>
		<pubDate>Fri, 23 Oct 2020 10:21:05 +0000</pubDate>
				<category><![CDATA[RunCloud]]></category>
		<guid isPermaLink="false">https://agusmu.com/?p=11</guid>

					<description><![CDATA[Using Nginx server-side caching, by default, a page with a query string will not be cached (BYPASS). But, some query strings should be cached for better performance, for example: utm_source utm_medium utm_campaign utm_expid fb_action_ids fb_action_types fb_source fbclid gclid If you use RunCloud Hub from RunCloud, you can enable cache on these query strings easily. Go [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Using <a href="https://blog.runcloud.io/nginx-fastcgi-cache/" rel="nofollow noopener" target="_blank">Nginx server-side caching</a>, by default, a page with a query string will not be cached (BYPASS).</p>
<p>But, some query strings should be cached for better performance, for example:</p>
<ul>
<li>utm_source</li>
<li>utm_medium</li>
<li>utm_campaign</li>
<li>utm_expid</li>
<li>fb_action_ids</li>
<li>fb_action_types</li>
<li>fb_source</li>
<li>fbclid</li>
<li>gclid</li>
</ul>
<p>If you use <a href="https://blog.runcloud.io/runcloud-hub/" rel="nofollow noopener" target="_blank">RunCloud Hub</a> from RunCloud, you can enable cache on these query strings easily.</p>
<p>Go to Settings &#8211; RunCloud Hub &#8211; RunCache &#8211; Rules, and enable the &#8220;<strong>Allow Cache Query String</strong>&#8221; option.</p>
<p><img loading="lazy" class="aligncenter wp-image-12 size-full" src="https://agusmu.com/wp-content/uploads/2020/10/runcloudhub-runcache-query-strings.png" alt="" width="926" height="552" /></p>
<h2>Ignore Caching Different Query String on Nginx FastCGI Cache</h2>
<p>The solution above is enough for most cases. But it will create a different cache for a different query string.</p>
<p>For example, these three links will create three different caches in the Nginx FastCGI cache.</p>
<pre>https://youdomain/sample-page/
https://youdomain/sample-page/?utm_source=facebook
https://youdomain/sample-page/?utm_source=email
</pre>
<p>If you heavily use the query strings above, you will probably want those links to be served using a single cache from the main page (without query string) URL.</p>
<pre>https://youdomain/sample-page/
</pre>
<p>When this post is published, this scenario is not supported by RunCloud. <em>(I will update this post when there is a change in the future).</em></p>
<p>Fortunately, we have full control of our server in RunCloud, so we will customize it to make it happen.</p>
<p><strong>First</strong>, you can create a custom Nginx config, choose the <code>location.http</code> type, and add this custom Nginx config.</p>
<pre><code>map $request_uri $request_path {
    ~(?&lt;captured_path&gt;[^?]*) $captured_path;
}</code></pre>
<p><strong>Second</strong>, log in to your server as the root user using OpenSSH/Terminal (Mac) or Putty/Powershell (Windows).</p>
<pre><code>ssh root@youripaddress</code></pre>
<p>Change <code>youripaddress</code> with your server IP Address.</p>
<p><strong>Third</strong>, edit one of Nginx config file, for example, I use nano to edit this file.</p>
<pre><code>nano /etc/nginx-rc/extra.d/webappname.location.proxy.runcloud-hub.conf</code></pre>
<p>Change <code>webappname</code> with current web application name in RunCloud.</p>
<p>Edit and replace <code>$request_uri</code> with <code>$request_path</code> on the cache key, so it will look like this.</p>
<pre><code>set $cache_key "$scheme$request_method$host$request_path";</code></pre>
<p><strong>Fourth</strong>, reload Nginx to apply the latest Nginx config update.</p>
<p>You can run this command to test your Nginx config configuration first,</p>
<pre><code>nginx-rc -t</code></pre>
<p>If the test was successful, then reload Nginx using this command,</p>
<pre><code>systemctl reload nginx-rc</code></pre>
<p>Done! Do not forget to use the Clear All Cache feature in RunCloud Hub and check the result.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://agusmu.com/nginx-fastcgi-cache-query-string/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
