On Varnish’s official website, there is a WordPress optimization guide For The Impatient: Preparing Varnish/Wordpress for a Slashdotting in 60 seconds or less….
The problem is that it removes cookie too aggressively. All non admin page will be virtually static. So I made my own vcl to remove cookies for only static files.
Here it is
backend default {
.host = "10.25.0.1";
.port = "80";
}
sub vcl_recv {
# Normalize Content-Encoding
if (req.http.Accept-Encoding) {
if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|lzma|tbz)(\?.*|)$") {
remove req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
remove req.http.Accept-Encoding;
}
}
# Remove cookies and query string for real static files
if (req.url ~ "^/[^?]+\.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.*|)$") {
unset req.http.cookie;
set req.url = regsub(req.url, "\?.*$", "");
}
# Remove cookies from front page
if (req.url ~ "^/$") {
unset req.http.cookie;
}
}
sub vcl_fetch {
if (req.url ~ "^/$") {
unset obj.http.set-cookie;
}
}
So all interactive pages will be sent to php backend with correct cookies. All static files and front page will be served by varnish proxy.
Yejun Web varnish, vcl, wordpress
This plugin will reduce uploaded image size in wordpress.
You will also need to install Optipng , Jhead and unsafe mode php.
These tools will only strip meta information of your images, therefore the result should be lossless.
You can download this plugin here.
Yejun Web images, plugin, wordpress
I updated 2 of my wordpress plugins.
Yejun Web plugin, wordpress
My 3rd WordPress plugins is here.
This plugin will improve javascript loading time by load them in parallel. More info can be found here.
Yejun Web javascript, optimization, performance, wordpress
General WordPress performance info
After all static files to cdn and move javascript out of html header. I also enabled multi CNAME cdn to see whether it increase page loading speed(not enabled in my cdn plugin yet, still testing). Here is the resault,
It seems CSS loading will still block css background images even those included in main html header. I also used Varnish to front proxy WordPress, because WordPress becomes extremely slow after move database from MyISAM to InnoDB.
Updates: I found 2 website helping draw water fall chart. Pagetest by AOL and Site-Perf.com.
Updates 2: I partly solved css image not preloading problem by insert an invisible img tag like this,
<img src="http://m1.cdnyy.com/x/wp-content/themes/aeros/images/autumn.jpg" alt="" height="1" width="1" style="border:0;display:none" />
But this only work in Chrome. IE will not load any image before css loaded.
Look at loading time of autumn.jpg, near 200ms improvement in Chrome.
Yejun Web optimization, wordpress
Check this out.
If your wordpress comments log is filled with local ips, you may give a try.
Yejun Web comments, plugin, spam, wordpress