Skip to content

Instantly share code, notes, and snippets.

@migliori
Last active February 13, 2024 06:29
Show Gist options
  • Save migliori/5737c943e67408f1b1cbff7694c15d0d to your computer and use it in GitHub Desktop.
Save migliori/5737c943e67408f1b1cbff7694c15d0d to your computer and use it in GitHub Desktop.
Apache mod_pagespeed cheatsheet #server #apache #mod_pagespeed

mod_pagespeed setup with WHM & cPanel

to add instructions to apache httpd.conf:

  • open WHM
  • go to Apache Configuration
  • open Include Editor & choose Pre VirtualHost Include
  • add instructions, ie:
  ModPagespeedEnableFilters add_instrumentation
  ModPagespeedMessageBufferSize 100000
  ModPagespeedStatistics on
  ModPagespeedStatisticsLogging on
  ModPagespeedLogDir /var/log/pagespeed
  ModPagespeedEnableCachePurge on
  ModPagespeedPurgeMethod PURGE
  
  <Location /mod_pagespeed_beacon>
        SetHandler mod_pagespeed_beacon
  </Location>
  
  <Location /mod_pagespeed_statistics>
      Order allow,deny
      Allow from 82.234.104.164
      SetHandler mod_pagespeed_statistics
  </Location>
  
  <Location /pagespeed_admin>
    Order allow,deny
    Allow from 82.234.104.164
    SetHandler pagespeed_admin
  </Location>
</IfModule>

.htaccess

  ModPagespeedDomain https://www.heritage-de-france.fr
  ModPagespeedDomain https://www.heritage-de-france.com
  ModPagespeedDomain https://www.2019.heritage-de-france.fr
  ModPagespeedDomain https://www.2019.heritage-de-france.com

# Disable rewriting for pagespeed_admin
  RewriteCond %{REQUEST_URI} pagespeed_admin/(.*)$
  RewriteRule ^ - [L,QSA]

  RewriteCond %{REQUEST_URI} mod_pagespeed_beacon/(.*)$
  RewriteRule ^ - [L,QSA]

  RewriteCond %{REQUEST_URI} mod_pagespeed_statistics/(.*)$
  RewriteRule ^ - [L,QSA]

#ModPagespeedLoadFromFile "https://www.my-website.com/" \
#                         "/home/www.my-website.com/public_html/"
</IfModule>

Clear cache

https://www.my-website.com/pagespeed_admin/cache?purge=/path/to/purge

Pagespeed Admin

https://www.my-website.com/pagespeed_admin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment