title: Change Twig cache file permissions to clear cache
body: <p>On the webserver I am working on, Twig 1.27 creates cache files with the Apache user and the permissions 755. </p>
  
  <pre><code>$ ls -la cache/
  total 4
  drwxrwxrwx 5 apache       apache         33 Jan 31 09:40 .
  drwxrwxrwx 5 apache       apache         4096 Jan 31 02:39 ..
  drwxr-xr-x 2 apache       apache         81 Jan 31 09:40 08
  drwxr-xr-x 2 apache       apache         81 Jan 31 09:40 4e
  drwxr-xr-x 2 apache       apache         81 Jan 31 09:40 92
  </code></pre>
  
  <p>I would like to clear the cache without obtaining su rights through a script. So I looked into the Twig files and found that it actually is set to write them with the permissions 777.</p>
  
  <p>lib/Twig/Cache/Filesystem.php</p>
  
  <pre><code>public function write($key, $content)
  {
      $dir = dirname($key);
      if (!is_dir($dir)) {
          if (false === @mkdir($dir, 0777, true) &amp;&amp; !is_dir($dir)) {
  </code></pre>
  
  <p>Why is Apache not writing the dirs/files with the 777 permissions?
  Alternatively is there a build in way in Twig to clear the cache?</p>