Tag Archives: pagespeed

google pagespeed – centos installation

 

Let’s edit/create google-mod-pagespeed.repo

vi /etc/yum.repos.d/google-mod-pagespeed.repo

and add

[googlemodpagespeed]
name=googlemodpagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/$basearch
enabled=1
gpgcheck=0
Let’s install it with yum!
yum install mod-pagespeed
Then we need to restart apache!
service httpd restart

 

This is how we test it…

curl -D- http://localhost/ | head -10

 

[root@sd-hooray webroot]# curl -D- http://localhost/ | head -10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4328 100 4328 0 0 27929 0 –:–:– –:–:– –:–:– 28103
HTTP/1.1 200 OK
Date: Wed, 12 Sep 2018 15:52:41 GMT
Server: Apache/2.4.6 (CentOS) PHP/5.6.38
X-Powered-By: PHP/5.6.38
X-Mod-Pagespeed: 1.13.35.2-0
Vary: Accept-Encoding
Cache-Control: max-age=0, no-cache, s-maxage=10
Content-Length: 4328
Content-Type: text/html; charset=iso-8859-1

 

 

pagespeed – Slow ReadFile operation on file

[Sat May 27 07:17:27.539747 2017] [pagespeed:error] [pid 19961] [mod_pagespeed 1.11.33.5-0 @19961] Slow ReadFile operation on file /var/cache/mod_pagespeed/rname/ic_QOs6thfRpiBUn09lB5Du/http,3A/,2Fdomain.com/assets/slideshow/slide_02.jpg,40x,40._,: 59.944ms; configure SlowFileLatencyUs to change threshold\n

 

Some disk stats….

sudo hdparm -Tt /dev/root

/dev/root:
 Timing cached reads: 26330 MB in 2.00 seconds = 13178.47 MB/sec
 Timing buffered disk reads: 540 MB in 3.00 seconds = 179.73 MB/sec

I’v added the following lines to my pagespeed configuration file (/etc/apache2/mods-enabled/pagespeed.conf)

ModPagespeedSlowFileLatencyUs 100

 

A More Efficient Method for Embedding YouTube Videos

When you embed any YouTube video on your website using standard IFRAME tags, you’ll be surprised to know how much extra weight that YouTube video will add to your page. The web page has to download ~0.5 MB of extra resources (CSS, JavaScript and images) for rendering the YouTube video player and the files will download even if the visitor on your website has chosen not to watch the embedded YouTube video.

Read all about it here http://www.labnol.org/internet/light-youtube-embeds/27941/

Breaking the PageSpeed Barrier with Bootstrap

I recently had the pleasure to listen to Ilya Grigorik give a talk at Velocity in NYC on Breaking the 1000ms Mobile Barrier. During the talk, Ilya usedPageSpeed Insights to demonstrate that several high profile websites had overlooked some very simple and common optimizations and resulted in poor PageSpeed scores. For the unfamiliar, Pagespeed Insights is a web based tool created by Google that analyzes the content of a web page, then generates suggestions to make that page faster.

After Ilya’s talk ended, I started to think more about why performance always seems to be an afterthought with developers. As I pondered this thought, I kept coming back to the following question:

How hard is it to get a perfect PageSpeed Insights score?

 

google pagespeed / gtmetrix – how to improve results

gtmetrix - results

Check if we have enabled mod_headers.c and mod_expires.c

First we need to check if we have enabled mod_headers.c and mod_expires.c.

sudo apache2 -l

If we don’t have it, we need to enable then

sudo a2enmod headers

Then we need to restart apache

sudo apache2 restart
Leverage browsers caching

By adding the following lines on .htaccess Leverage Browsers Caching has simply disappeared! I got the solution from http://stackoverflow.com/questions/6878427/leverage-browser-caching-how-on-apache-or-htaccess

ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>

It went from a global score of 53% to 72%.
And F(1) to A(98).

Enable gzip compression
<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE application/javascript
 AddOutputFilterByType DEFLATE application/rss+xml
 AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
 AddOutputFilterByType DEFLATE application/x-font
 AddOutputFilterByType DEFLATE application/x-font-opentype
 AddOutputFilterByType DEFLATE application/x-font-otf
 AddOutputFilterByType DEFLATE application/x-font-truetype
 AddOutputFilterByType DEFLATE application/x-font-ttf
 AddOutputFilterByType DEFLATE application/x-javascript
 AddOutputFilterByType DEFLATE application/xhtml+xml
 AddOutputFilterByType DEFLATE application/xml
 AddOutputFilterByType DEFLATE font/opentype
 AddOutputFilterByType DEFLATE font/otf
 AddOutputFilterByType DEFLATE font/ttf
 AddOutputFilterByType DEFLATE image/svg+xml
 AddOutputFilterByType DEFLATE image/x-icon
 AddOutputFilterByType DEFLATE text/css
 AddOutputFilterByType DEFLATE text/html
 AddOutputFilterByType DEFLATE text/javascript
 AddOutputFilterByType DEFLATE text/plain
 # Remove browser bugs (only needed for really old browsers)
 BrowserMatch ^Mozilla/4 gzip-only-text/html
 BrowserMatch ^Mozilla/4\.0[678] no-gzip
 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 Header append Vary User-Agent
</IfModule>
<IfModule mod_gzip.c>
 mod_gzip_on Yes
 mod_gzip_dechunk Yes
 mod_gzip_item_include file .(html?|txt|css|js?|php|pl)$
 mod_gzip_item_include handler ^cgi-script$
 mod_gzip_item_include mime ^text/.*
 mod_gzip_item_include mime ^application/x-javascript.*
 mod_gzip_item_exclude mime ^image/.*
 mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
Defer parsing of JavaScript

To solve this issue I’v installed Asynchronous Javascript WordPress plugin.
It went from a score of F (19) to B (85).

 

 

Google Chrome 53

 

I strongly recommend to install Google PageSpeed module.
Small tutorial https://www.digitalocean.com/community/tutorials/how-to-get-started-with-mod_pagespeed-with-apache-on-an-ubuntu-and-debian-cloud-server