I recently migrated my WordPress site to Windows Azure. My main goal was to increase the overall performance of my site. I wanted a site which responded in less that 1 second on ANY device, from ANYWHERE, at ANYTIME, for ANYONE!
To enhance performance, I implemented several things. However, the biggest role player was “W3 Total Cache”. For those of you familiar with “W3 Total Cache” you know it’s the de facto performance plugin for WordPress. The plugin is amazing. It supports a ton of features such as page, object, browser and database cache, JS/CSS/HTML minify and CDN support. All aimed at making your WordPress site blazing fast.
After soft launching my blog, I begun to notice a pattern. My site would run for a while, a couple of hours, and then suddenly stop responding to requests. Using the tools at Pingdom I would confirm my site was, in fact, down. Attempts to navigate to my site would result in “502 – Web server received an invalid response while acting as a gateway or proxy server.” errors. I attempted to diagnosis the problem using php logging, web and event logs, etc. Unfortunately, the errors were vague and led nowhere.
My first guess was a database issue. My reasoning had to do with the fact that I would occasionally, and randomly, receive “Error establishing database connection” errors when navigating or performing admin work on my site. So I upgraded my ClearDb to the $10 month plan. That didn’t fix the problem. I then fiddled with “W3 Total Cache”, turning knobs off and on and tweaking settings. Nothing. Then I found a forum post on MSDN talking about particular settings for “W3 Total Cache” running on Azure. Specially, page caching and database and object caching. I gave it a shot, despite the post being dated from 2011, it worked!
Here are the settings for running “W3 Total Cache” under Azure:
Under “General Settings” >>
- Page Cache – used “Opcode: Wincache”
- Minify – Minify cache method used “Opcode: Wincache”
- Disable Object Cache
- Disable Database Cache
I hope this fixes your 502 errors. If it works for you, let me know in the comments below!