Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8120869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:17:35+00:00 2026-06-06T05:17:35+00:00

i’m trying to figure out how to check if ModPagespeed is enabled and allowed

  • 0

i’m trying to figure out how to check if ModPagespeed 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.

Excerpt from .htaccess (serving different domains) with Pagespeed filters:

<IfModule pagespeed_module>
  ModPagespeed On
  ModPagespeedRewriteLevel PassThrough
  ...
  ModPagespeedEnableFilters combine_css
  ...
</IfModule>

Excerpt from pagespeedtest.html:

...
<head>
...
  <!-- If combine_css filter is active, the following code should be combined -->
  <style type="text/css" media="all">@import url("/style1.css");</style>
  <style type="text/css" media="all">@import url("/style2.css");</style>
  <style type="text/css" media="all">@import url("/style3.css");</style>
...
</head>

Check if Pagespeed is enabled or allowed by this PHP 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;
        }

I get the Content-Length header using the PHP 5 function get_headers($url). 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.

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 combine_css filter will be disabled, I will got $pagespeed_is_active == FALSE even when ModPagespeed is On and allowed.

An alternative solution must be validated through different domains, since I can disallow some domains in this very same .htaccess. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:17:37+00:00Added an answer on June 6, 2026 at 5:17 am

    Instead of checking the Content-Length, you can instead look for the X-Mod-Pagespeed header, which will give you the answer you’re looking for as long as “ModPageSpeed on” directive is there for the domain.

    Other then that, I don’t think there is any way for you to check if PageSpeed is enabled from within the request. The whole point of PageSpeed is that it runs as an output filter: you generate your page, PageSpeed picks it up and does the optimization and rewriting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to create an if statement in PHP that prevents a single post
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.