What absolutely should not be cached?

I've been experimenting with a varnish reverse proxy and have had considerable success in that I am able to cache all content (static and dynamic) for non logged in users now.  However I am running into little papercuts such as anonymous comments don't work and new registration does not work with the spam_login_filter plugin enabled (but it works fine with it disabled).  Another small issue is the system/error messages are not being displayed to users who say try to register (but once they actually log in it is fine).

I was wondering if anyone had any recommendations as far as what content absolutely should not be cached?  By this I mean it is okay to cache say an izap-video view count or even the entire display page (which I am only doing for 15 minutes or so).  But it's not okay say to cache something which interferes with makuing new anonymous comments (that they are delayed by the cache time is expected however) via the speak freely or moderate comments plugins.

So far I have the following set up to not be cached at all:

1. Any content for any user which is logged in. (using a special cookie I setup)

2. Any url with any of the following words: comment, captcha, admin, register, login

3. Any request method other than GET or HEAD.

Does anyone else have any suggestions?  Are there any other url patterns or say headers which I should also consider for blacklisting from the cache?

Note: blacklisting the "elgg" token/cookie from being cached unfortunately isn't an option in my case.

Thank you.



  • Seems you are reinventing the wheel. If you are looking for page caching for guest users take a look at http://community.elgg.org/plugins/1151103/1.1/gallicache

  • Thanks.  That looks very interesting.  I might be able to use it.  Does it change the type of data being returned to the user such as changing a page which would contain dynamic php queries to one which appears to be static html?  I'm interested in learning more about how it works and I think I might give it a shot on another server I have to test.

    I think the varnish idea is a bit different though.  Doing this the request doesn't hit apache, mysql, or php at all.  It's entirely served by varnishd and depending on the config it may not ever hit the disk if the varnish cache file is fully in memory.  I woke up today to varnishstat showing a hit rate of 84% after running overnight and a 15m load average of 0.16.  And that is with many cache purges due to the varnish cache size plus there are a couple uncached sites on that server so I suspect the cache rate on the Elgg sites alone is now up to 90% and with some tweaking could reach 95%.  This has extreme implications for scaling on a single server when you can get a varnish hitrate that high.

    I just wish some of the little paper cuts could be solved.  For example using the drop down login form doesn't work right most of the time now.  The user is told they are trying to login from a different domain and is taken to the full login page.  But then after logging in there it works fine.  I guess one way to workaround is to eliminate the dropdown and make it so clicking it simply takes you to the full login page.  I bet there are better ways though.  The annoyances are there but at the moment for me it seems worth it given the improvement in capacity and speed.