<div dir="ltr">Possible optimization<br><br>Hi!<br><br>I&#39;m using a CGI program that includes fontconfig. (<a href="http://www.websequencediagrams.com">http://www.websequencediagrams.com</a>). I noticed that when I ran my program from the command line, it was taking 0.025 s to run. However, when apache2 ran it, it took about 1.5 seconds every time. This is even after running &#39;fc-cache -f&#39; as root.<br>
<br>The culprit was fontconfig. In the /etc/fonts/fonts.conf supplied with Ubuntu 7.04, we have:<br><br>&lt;cachedir&gt;/var/cache/fontconfig&lt;/cachedir&gt;<br>&lt;cachedir&gt;~/.fontconfig&lt;/cachedir&gt;<br><br>When run by the www-data user (as a cgi-script), there is no ~/.fontconfig, so it was regenerating the cache each time.<br>
<br>Executing &quot;chmod a+w -R /var/cache/fontconfig&quot; solved the problem. Now fontconfig is fast even when executed by a cgi program.<br><br>I&#39;m trying to understand what is happening here. Why can fontconfig only use the /var/cache/fontconfig folder if it is writable? And why does it regenerate the cache every time, even after fc-cache is run?<br>
<br></div>