Why does mod_rewrite slow down my web site significantly?
<p>I have a website <code>mywrapper.com</code> that does nothing but redirect to a specific page in another domain, <code>http://www.example.com/coming-soon.html</code> using mod_rewrite. However, the redirects are <strong>incredibly</strong> slow. The first redirection from (say) <code>mywrapper.com/foo</code> takes 5-10 seconds or more. Subsequent redirects from <code>mywrapper.com/foo</code> are immediate. (This behavior happens for any page, not just <code>foo</code>.) Any ideas why?</p>

<p>My apache config (<code>/etc/apache2/sites-enabled/mywrapper.com.conf</code>) is as follows:</p>

<pre><code>&lt;VirtualHost *:80&gt;
  ServerAdmin webmaster@mywrapper.com
  ServerName  www.mywrapper.com
  ServerAlias mywrapper.com

  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^mywrapper\.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www\.mywrapper\.com$
  RewriteRule ^\/?(.*)$ "http\:\/\/www\.example\.com\/coming-soon.html" [R=301,L]

  LogLevel warn
  ErrorLog  /var/www/html/mywrapper.com/log/error.log
  CustomLog /var/www/html/mywrapper.com/log/access.log combined
&lt;/VirtualHost&gt;
</code></pre>

<p>Hitting <code>http://www.example.com/coming-soon.html</code> directly is instantaneous.</p>

<p>The webserver (same machine hosts both domains) has 2GB RAM and is not swapping, so free memory doesn't seem to be the issue. It runs a fairly vanilla Ubuntu 16.04 LTS setup. There are no errors in the Apache logs.</p>

<p>Thanks for any insights.</p>