<h2 dir="auto">What</h2>
<p dir="auto">This pull request introduce three new environment variables that allows you to control the cache behavior of this Rails application</p>
<ul dir="auto">
<li><code class="notranslate">RAILS_DEV_CACHE</code></li>
<li><code class="notranslate">RAILS_PAGE_CACHE</code></li>
<li><code class="notranslate">RAILS_FILE_CACHE_DIR</code></li>
</ul>
<h2 dir="auto">Why</h2>
<p dir="auto">This Rails app currently have several problem about caching, especially docker compose environment</p>
<ul dir="auto">
<li>docker compose environment does not persists <code class="notranslate">/app/tmp</code> directory
<ul dir="auto">
<li>This means that the file <code class="notranslate">/app/tmp/caching-dev.txt</code> will be lost each time docker compose is restarted</li>
</ul>
</li>
<li>Even if cache is enabled in the development environment, <code class="notranslate">config.action_controller.page_cache_directory</code> is not enabled</li>
<li>Cache mechanism can only select memory_store, so every cache is lost after restart this rails app</li>
</ul>
<h2 dir="auto">How</h2>
<ul dir="auto">
<li>I've changed <code class="notranslate">config/environments/development.rb</code>
<ul dir="auto">
<li>All changes refer to new environment variables</li>
<li>If they are not specified, the behavior is the same as before</li>
</ul>
</li>
<li>I've added file named <code class="notranslate">docker-compose.override.example.yml</code> and edit <code class="notranslate">.gitignore</code> to ignore file named <code class="notranslate">docker-compose.override.yml</code>
<ul dir="auto">
<li>The file named <code class="notranslate">docker-compose.override.yml</code> can override behavior of the <code class="notranslate">docker-compose.yml</code> settings when run-time</li>
<li>This is a common way for developers to change the behavior of Docker applications</li>
<li><a href="https://docs.docker.com/compose/extends/" rel="nofollow">https://docs.docker.com/compose/extends/</a></li>
<li><code class="notranslate">docker-compose.override.example.yml</code> shows how to override <code class="notranslate">docker-compose.yml</code> to persists <code class="notranslate">/app/tmp</code> dir and to enable environment variables I proposed on this pull request</li>
<li>You can use it by <code class="notranslate">cp docker-compose.override.example.yml docker-compose.override.yml</code></li>
</ul>
</li>
</ul>
<h2 dir="auto">My opinion</h2>
<ul dir="auto">
<li>I don't know how the decision was made not to persist /app/tmp in Docker, but this may be a problem</li>
<li>Adding <code class="notranslate">docker-compose.override.yml</code> to <code class="notranslate">.gitignore</code> so that it can be freely written is also done in various other projects</li>
<li>I want to be able to make the cache persistent in my dev env
<ul dir="auto">
<li>I believe that file_store cache is slower than memory_store cache, but it should be faster than the XML building process on every requests</li>
</ul>
</li>
<li>Please let me know if you have any comments on the naming of environment variables.</li>
</ul>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/3812'>https://github.com/openstreetmap/openstreetmap-website/pull/3812</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/3812/commits/36fe2311c46e2c1fff66f7555fb667af15505874" class="commit-link">36fe231</a>  Allows control of cache behavior in the dev env via environment variables</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/3812/files">3 files</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3812/files#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947">.gitignore</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3812/files#diff-d3c4b3f41072daa416f1920511e9b2e26caea8c5cec0a14cb9508589a4dafa47">config/environments/development.rb</a>
    (20)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3812/files#diff-b9ff348a02c01957b855d68cc7b718d5bb7458ea9cf9d43007d42208b897aa90">docker-compose.override.example.yml</a>
    (8)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/3812.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/3812.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/3812.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/3812.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3812">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLKGCQJOOC5QK2WXDCLWJIXMXANCNFSM6AAAAAASF3XJPY">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJYMTAQU2DZDQDZOQTWJIXMXA5CNFSM6AAAAAASF3XJP2WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHFNVWXRI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/3812</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/3812",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/3812",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>