You Are Here: Home » HowTos » Using Mod Page Speed for your website

Using Mod Page Speed for your website

PageSpeed

Fast and optimized pages lead to higher visitor engagement, retention, and conversions. The PageSpeed family of tools is designed to help you optimize the performance of your website. PageSpeed Insights products will help you identify performance best practices that can be applied to your site, and PageSpeed optimization tools can help you automate the process

Installing mod_pagespeed from packages

First we need to download the packages
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
To install the Packages on Debian/Ubuntu run these commands
dpkg -i mod-pagespeed-*.deb
apt-get -f install

Enabling the module
a2enmod pagespeed
Checking that mod expire is enabled
ls -al /etc/apache2/mods-enabled/ | grep expires.load
if the result is empty that means the module is not enabled, to enable it run these commands
a2enmod expires
/etc/init.d/apache2 reload

Exemple of a configuration file
vim /etc/apache2/mods-enabled/pagespeed.conf

[sourcecode language="css"]<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedInheritVHostConfig on
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedFileCachePath "/var/mod_pagespeed/cache"
ModPagespeedEnableFilters extend_cache
ModPagespeedEnableFilters rewrite_javascript,rewrite_css
ModPagespeedEnableFilters collapse_whitespace,elide_attributes,remove_comments
ModPagespeedEnableFilters insert_img_dimensions,move_css_to_head,add_head,combine_heads
ModPagespeedModifyCachingHeaders off
ModPagespeedDomain terraltech.com
<FilesMatch ".(jpg|jpeg|gif|png|js|css|html)$">
Header unset Etag
Header set Cache-control "public, max-age=10800"
</FilesMatch>
<FilesMatch ".(js)$">
Header unset Etag
Header set Cache-control "public, max-age=604800"
</FilesMatch>
ModPagespeedFileCacheInodeLimit 500000
ModPagespeedAvoidRenamingIntrospectiveJavascript on
<Location /mod_pagespeed_beacon>
SetHandler mod_pagespeed_beacon
</Location>
<Location /mod_pagespeed_statistics>
Order allow,deny
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_statistics
</Location>
<Location /mod_pagespeed_console>
Order allow,deny
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_console
</Location>
ModPagespeedMessageBufferSize 100000
<Location /mod_pagespeed_message>
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_message
</Location>
<Location /mod_pagespeed_referer_statistics>
Allow from localhost
Allow from 127.0.0.1
SetHandler mod_pagespeed_referer_statistics
</Location>
</IfModule>
[/sourcecode]

Checking Apache configuration
apache2ctl -t
Don’t forget to reload your Apache server
/etc/init.d/apache2 reload
To check that your PageSpeed is working you can compare your result by running your website with FireBug/PageSpeed console running or open the mod_pagespeed_statistics URL
For exemple http://terraltech.com/mod_pagespeed_statistics/
make sure that in the pagespeed.conf your are allowed to open it.
You can also check the Http Headers to see the expiration date, you can use the “Live HTTP Header” add-on to Firefox

See Also:

Clip to Evernote

About The Author

Network and system engineer

Number of Entries : 44

Comments (1)

Leave a Comment


five × 1 =

Scroll to top