nginx reverse proxy with caching

Playing around and searching the web I enabled some decent caching now.

Here are some stats: image+html and php. Note that the php on apache (recompiled each request, about 1.5-2sec between every request) versus the cached output has a huge difference. Difference between images and static text files aren’t that huge. Also note that nginx has gzip enabled. The downside is that nginx caches all pages (HTTP code 200) for one hour and isn’t notified when pages are modified (yet).

My “live” blog is also accessible using blog.yeri.be as blog.tuinslak.org will now point to the nginx reverse proxy.

I’ve come across a few issues though, pages such as this (shows your current IP address) and this (compare to this and refresh a few times) are cached as well, and actually show the previous visitor (if any) their output and the pages aren’t updated when a new visitor visits them. Edit: fixed, correctly refreshes; *.php under wp-* isn’t cached.

Same goes for layout (I use WPtouch for mobile devices). A page that got visited on the iPhone and then on a desktop as well as a page that got first cached using a desktop browser and then an iPhone. I’ve disabled WPtouch for now.

And a 3rd issue is that the WordPress stats image () is cached as well. So if a regular visitor visits the site before a a registered user (admin), the stats image will still be present (and generate incorrect stats). This doesn’t happen the other way around, as no pages are cached for a registered user (unless they are already in its cache)… Weird. Edit: fixed by watching the http cookie and this plugin. Admin pages are never cached now but at least stats are correct again.

Speed gain is insane though.

Leave a Reply...