Monday, December 7, 2009 2:57 PM kehand

pre-caching PHP Web Applications WITH wincache and Application Warm-up

Using Wincache and Application Warm-Up together can allow you to create a cache for your PHP web applications before any request arrives. This will enable you to not only have scheduled server recycles without any downtime, but will also save you the initial compilation time of the first requests to a webpage.

It should be noted that Application Warm-Up is only available for Windows Server 2008 R2. You can use the Web Platform Installer to install everything in this post – Wincache, Application Warm-Up, PHP, and the web applications.

For this post, I will be using Acquia Drupal, Gallery2, and Wordpress for examples. After installing and performing the initial setup phases of the web applications, the first step is to enable Application Warm-Up’s ability to start the application pool when the service is started. This is done in the site(s) that contain your web applications.

image

The next step is to add the relative URI paths to the web pages that need to be cached. Typically, this should include the most frequently hit or most computationally intensive pages. For Acquia Drupal and Wordpress, this means adding warm-up requests for /index.php. For Gallery2, the page most frequently viewed is typically /main.php.

To do this, navigate to the site or the application that contains your web application, and click Application Warm-Up. Clicking Add Request… will lead you to a dialog box where you can add the URI.

image

image

The same should be done for your other sites (in my case, Acquia Drupal and Gallery).

image

image You can test out the settings by doing a quick iisreset and then navigating to wincache.php (which can be found in %programfiles(x86)%\iis\windows cache for php) to check out the results.

image

image 

You can also take advantage of this by having scheduled recycles that can be found in the application pool that contains your web sites. When the recycle takes place, Application Warm-Up will keep old worker processes active while the recycle is taking place so that no downtime occurs. Furthermore, the new worker processes will already have the cached pages ready to go for the new requests.

image

Hope this helps!

Comments

No Comments