Turbocharge Apache with mod_pagespeed from Google
The Dream
Imagine that with just few clicks you could speed up your slow website - sounds very tempting but is it really possible? Trust me it is! Sounds like I am trying to sell magical cure for hangover or German used diesel car with 50000 km which was driven by old grandpa only to church and back.
The Reality
Reality is quite simple - Google made a really good work to implement websites performance best practices into one piece of software which is really easy to use. Of course what Google prepared is well known for all website coders and geeks. For normal people who prefer to click and forget this is very useful. You can read more about website best practices https://developers.google.com/speed/docs/insights/rules.
What to do master - teach me!
Hold your horses young padawan. Here are prerequisites you need to fulfill:
- your server must have Apache 2.x installed
- if you are running CentOS/Fedora (32-bit and 64-bit) or Debian/Ubuntu (32-bit and 64-bit) and you want to install RPM’s / DEB’s download them from this page https://developers.google.com/speed/docs/mod_pagespeed/download
- if you prefer compiling sources follow this link https://developers.google.com/speed/docs/mod_pagespeed/build_from_source
Nonstandard httpd config files
Important notice for servers with non-standard configuration files. If for any reason your httpd config is located in different location for example in /etc/httpd/conf/httpd.conf (rather than in /etc/httpd/conf.d/)
Then you need to load mod_pagesped by modifying /etc/httpd/conf/extra/httpd-includes.conf by this: Include /etc/httpd/conf.d/pagespeed.conf
After you loaded mod_pagespeed check if it is loaded correctly (in CentOS apachectl -M) and now it is time to configure goodies.
I will share optimizations I enabled on my webserver:
#Images
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters insert_img_dimensions
ModPagespeedEnableFilters convert_gif_to_png
ModPagespeedEnableFilters convert_jpeg_to_progressive
ModPagespeedEnableFilters jpeg_subsampling
ModPagespeedEnableFilters recompress_jpeg
ModPagespeedEnableFilters recompress_png
ModPagespeedEnableFilters recompress_webp
ModPagespeedEnableFilters strip_image_color_profile
ModPagespeedEnableFilters strip_image_meta_data
ModPagespeedEnableFilters sprite_images
#CSS
ModPagespeedEnableFilters move_css_above_scripts
ModPagespeedEnableFilters outline_css
ModPagespeedEnableFilters rewrite_css
ModPagespeedEnableFilters inline_css
ModPagespeedEnableFilters combine_css
#JavaScript
ModPagespeedEnableFilters rewrite_javascript
ModPagespeedEnableFilters defer_javascript
ModPagespeedEnableFilters inline_javascript
ModPagespeedEnableFilters outline_javascript
#Cache
ModPagespeedEnableFilters extend_cache
#Others
ModPagespeedEnableFilters remove_quotes
ModPagespeedEnableFilters collapse_whitespace,elide_attributes
ModPagespeedEnableFilters remove_comments
#Domain
ModPagespeedDomain https://www.wojcieh.net
After that overall speed of website is very fast. It is not only personal feeling but tests like Pingdom Tools, Google PageSpeed Insights, Yslow also confirm that. I hope you will at least try it - it will not harm you, it will not take long to implement - but trust me results are incredible and you will not regret it.
Documentation is located here http://code.google.com/p/modpagespeed/