Website Performance

Allow Plugins to Short-circuit wp_nav_menu

Database queries necessary for wp_nav_menu

I  just submitted my second WordPress core patch that adds a short-circuit filter at the top of wp_nav_menu which enables plugins to retrieve rendered menu output from a transient or non-persistent cache instead of relying on relatively complex database query that returns one of the most static items of every website.

Why is this important?

To illustrate the complexity of menu retrieval, here is a list of all database queries that are run on every page load:

  1. Retrieve term object of the nav_menu taxonomy that corresponds to the specific menu name.
  2. Retrieve menu item IDs (not complete post objects, yet) that are in the particular term.
  3. Query for menu item post objects with the specific IDs and retrieve three post_meta values per each menu item.
  4. Retrieve post and term objects corresponding to each menu item (map every nav_menu_item post to the actual post, page or archive page).

and here are the corresponding query samples:  Read more »

Link: Moving Beyond End-to-End Path Information to Optimize CDN Performance

Moving Beyond End-to-End Path Information to Optimize CDN Performance

Our main result is that redirecting every client to the server with least latency does not suffice to optimize client latencies. First, even though most clients are served by a geographically nearby CDN node, a sizeable fraction of clients experience latencies several tens of milliseconds higher than other clients in the same region. Second, we find that queueing delays often override the benefits of a client interacting with a nearby server.

Fixing /etc/init.d/php5-fpm Init Script for PHP 5.4 (from Dotdeb) on Debian Squeeze

I recently updated my server to PHP 5.4 and discovered that I was no longer able to restart the PHP-FPM service using the regular:

$ /etc/init.d/php5-fpm restart

or

$ service php5-fpm restart

I went to the official Debian GIT repository for the PHP 5.4 beta package and found the following differences between the init scripts (here is the one from Dotdeb):

Replacing my init script with the one from the official beta package solved the problem. I wonder what export ZEND_DONT_UNLOAD_MODULES=1 does wrong.

Super Easy Responsive Images with Viewport Cookies

Here is the idea behind the Viewport Cookies:

  1. first, detect the width of the device viewport using javascript and store its value in a viewport cookie from within the <head>;
  2. use that cookie in the backend (with Nginx image_filter or a PHP script) to resize, cache and serve images of appropriate size for that particular viewport.

The great thing about this method is that it doesn’t require any modifications to the image tags and the javascript is kept to the bare minimum.

Adaptive Images with Viewport Cookies

Part 1: Store the Screen Width in a Cookie Using Javascript

Javascript is the only thing that can detect parameters such as browser window dimensions and device screen size, so we have to use javascript until (and if) browsers start setting this data in HTTP request headers. Read more »

History of Nginx

Igor Sysoev:

In spring 2001 I had written Apache mod_accel that is enhanced replacementof mod_proxy. But it was clear that Apache has low scalability. I had read http://kegel.com/c10k.html, had investigated existent servershttpd, boa, etc. and had decided that I need something like these servers, but with SSI, proxy, and cache support. Also it should has flexible configuration like Apache and supports online upgrade and quick log rotation.

As an aside, I’ve always been a bit curious about the name.

The base for name was NG letters those sounds like en-gee in English (I at least I think so :). X is simply fine letter. But ngx was already used many times. There were some variants – ngnx, nginx and nginex. nginx seemed the better for me and I had look it in Google and found the only quote symbol.

via history of Nginx.

Enable WordPress Plugin, Theme Updates and Pretty Permalinks on Nginx

WordPress doesn’t know that your Nginx web server is capable of doing URL rewrites without mod_rewrite and Apache, so we explain that by adding:

add_filter('got_rewrite', 'nginx_has_rewrites');
function nginx_has_rewrites() {
	return true;
}

in your theme’s functions.php.

It is very likely that along Nginx you are also running PHP-FPM for all your PHP needs, and for some reason WordPress thinks its PHP process can’t write to disk. We tell WordPress that it can:

add_filter('filesystem_method', 'nginx_make_filesystem_direct');
function nginx_make_filesystem_direct() {
	return 'direct';
}

Page 1 of 3