PageSpeed: Optimize Your Rendered Code On The Fly
Software version | 1.7.30.3 |
Operating System | Debian 7 |
Website | PageSpeed Website |
Others | Nginx 1.4.4-1 |
Introduction
PageSpeed1 speeds up your site and reduces page load time. This open-source webserver module automatically applies web performance best practices to pages and associated assets (CSS, JavaScript, images) without requiring that you modify your existing content or workflow.
Installation
As Wheezy has an outdated version of Nginx, we’re going to use Nginx extras package with PageSpeed built-in. To get it, we will use the well-known DotDeb repository.
To install DotDeb repository, add a preference file to avoid unwanted override packages:
|
|
Then add the repository:
|
|
Add the GPG key:
|
|
And run an update:
|
|
Then you can install nginx with pagespeed integrated:
|
|
Configuration
The configuration is quite easy but there are lots of options that need to be tested one by one to be sure they have the correct effect:
|
|
Then apply this configuration to your desired virtual host:
|
|
And reload Nginx for changes to take effect. You can also enable pagespeed on the server side directly to apply the configuration to all vhosts at once.
File path cache optimization
The file path cache is used to store rewritten elements. So it’s preferable to have good performance on it, and to achieve this, you can use a tmpfs. Add this line to your fstab:
|
|
And then create the folder and mount it:
|
|
Restart nginx and it’s ready!
Benchmark
Several websites exist to benchmark your site and give you recommendations:
- GTMetrix: http://gtmetrix.com
- Page Speed Insight: http://developers.google.com/speed/pagespeed/insights
Then try to correlate with PageSpeed options and you’re now ready to perform tests and see the awesome results!
References
Last updated 19 Feb 2014, 17:14 +0200.