Web Optimization (Nginx, Pagespeed)
These are some tools and hint to optimization your site.
Test page optimization:
Pagespeed
Remove old Nginx
sudo aptitude remove nginx nginx-full nginx-common
Install Pagespeed:
sudo add-apt-repository ppa:sandyd/nginx-current-pagespeed
sudo aptitude update
sudo aptitude install nginx
Nginx config:
pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache; # Use tmpfs for best results.
# without any space and don't forgot ","
pagespeed EnableFilters convert_jpeg_to_webp,lazyload_images,insert_image_dimensions,collapse_whitespace;
# let's speed up PageSpeed by storing it in the super duper fast memcached
pagespeed MemcachedThreads 1;
pagespeed MemcachedServers "localhost:11211";
# Ensure requests for pagespeed optimized resources go to the pagespeed
# handler and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
access_log off;
add_header "" "";
}
location ~ "^/ngx_pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
location /pagespeed_console { allow 127.0.0.1; deny all; }
Checkout which filters enables
Debug errors if you have made mistakes in the cinfig files by:
sudo nginx -t
Nginx compression
/etc/nginx/mime.types
config: /etc/nginx/nginx.conf
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype;
Nginx error:
Debug errors if you have made mistakes in the cinfig files by:
sudo nginx -t
Ref: