title: Check if ModPagespeed is allowed and enabled for the current domain via php
body: <p>i'm trying to figure out how to check if <a href="http://code.google.com/p/modpagespeed/" rel="nofollow">ModPagespeed</a> is enabled and allowed on the current domain via PHP. I've written the following code, but I'm not fully satisfied of this solution. It works, but it's a crock.</p>
  
  <p>Excerpt from .htaccess (serving different domains) with <a href="https://developers.google.com/speed/docs/mod_pagespeed/config_filters" rel="nofollow">Pagespeed filters</a>:</p>
  
  <pre><code>&lt;IfModule pagespeed_module&gt;
    ModPagespeed On
    ModPagespeedRewriteLevel PassThrough
    ...
    ModPagespeedEnableFilters combine_css
    ...
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Excerpt from pagespeedtest.html:</p>
  
  <pre><code>...
  &lt;head&gt;
  ...
    &lt;!-- If combine_css filter is active, the following code should be combined --&gt;
    &lt;style type="text/css" media="all"&gt;@import url("/style1.css");&lt;/style&gt;
    &lt;style type="text/css" media="all"&gt;@import url("/style2.css");&lt;/style&gt;
    &lt;style type="text/css" media="all"&gt;@import url("/style3.css");&lt;/style&gt;
  ...
  &lt;/head&gt;
  </code></pre>
  
  <p>Check if Pagespeed is enabled or allowed by this PHP code:</p>
  
  <pre><code>        $psturl = 'http://'. $_SERVER['HTTP_HOST'] .'/pagespeedtest.html';
          $pagespeed_is_active = TRUE;
          $pstheaders = get_headers($psturl, 1);
          if ($pstheaders['Content-Length'] == 960) {
            $pagespeed_is_active = FALSE;
          }
  </code></pre>
  
  <p>I get the Content-Length header using the PHP 5 function <a href="http://php.net/manual/en/function.get-headers.php" rel="nofollow">get_headers($url)</a>. I know the original file is 960 bytes long so I suppose that if no optimization is performed the Content-Length should be the same when served to the client.</p>
  
  <p>Are there any alternatives to this approach? I don't like the supplemental HTTP request I perform on pagespeedtest.html and that solution strongly relies on PageSpeed configuration: if <kbd>combine_css</kbd> filter will be disabled, I will got <kbd>$pagespeed_is_active == FALSE</kbd> even when ModPagespeed is <kbd>On</kbd> and allowed.</p>
  
  <p>An alternative solution must be validated through different domains, since I can disallow some domains in this very same .htaccess. Thank you.</p>